Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcbba55d

Browse files
committed
Support min/max index optimizations on boolean columns.
Since bool_and() is equivalent to min(), and bool_or() to max(), we mightas well let them be index-optimized in the same way. The practical valueof this is debatable at best, but it seems nearly cost-free to enable it.Code-wise, we need only adjust the entries in pg_aggregate. There is ameasurable planning speed penalty for a query involving one of theseaggregates, but it is only a few percent in simple cases, so that seemsacceptable.Marti Raudsepp, reviewed by Abhijit Menon-Sen
1 parent3db6524 commitcbba55d

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201202082
56+
#defineCATALOG_VERSION_NO201202083
5757

5858
#endif

‎src/include/catalog/pg_aggregate.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ DATA(insert ( 2828float8_regr_accumfloat8_covar_samp01022"{0,0,0,0,0,0}" )
205205
DATA(insert (2829float8_regr_accumfloat8_corr01022"{0,0,0,0,0,0}" ));
206206

207207
/* boolean-and and boolean-or */
208-
DATA(insert (2517booland_statefunc-016_null_ ));
209-
DATA(insert (2518boolor_statefunc-016_null_ ));
210-
DATA(insert (2519booland_statefunc-016_null_ ));
208+
DATA(insert (2517booland_statefunc-5816_null_ ));
209+
DATA(insert (2518boolor_statefunc-5916_null_ ));
210+
DATA(insert (2519booland_statefunc-5816_null_ ));
211211

212212
/* bitwise integer */
213213
DATA(insert (2236int2and-021_null_ ));

‎src/test/regress/expected/opr_sanity.out

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -774,16 +774,19 @@ WHERE a.aggfnoid = p.oid AND
774774
(0 rows)
775775

776776
-- Cross-check aggsortop (if present) against pg_operator.
777-
-- We expect to findonly "<"for"min" and ">" for "max".
777+
-- We expect to findentriesforbool_and, bool_or, every,max, and min.
778778
SELECT DISTINCT proname, oprname
779779
FROM pg_operator AS o, pg_aggregate AS a, pg_proc AS p
780780
WHERE a.aggfnoid = p.oid AND a.aggsortop = o.oid
781-
ORDER BY 1;
782-
proname | oprname
783-
---------+---------
784-
max | >
785-
min | <
786-
(2 rows)
781+
ORDER BY 1, 2;
782+
proname | oprname
783+
----------+---------
784+
bool_and | <
785+
bool_or | >
786+
every | <
787+
max | >
788+
min | <
789+
(5 rows)
787790

788791
-- Check datatypes match
789792
SELECT a.aggfnoid::oid, o.oid
@@ -816,11 +819,14 @@ WHERE a.aggfnoid = p.oid AND a.aggsortop = o.oid AND
816819
amopopr = o.oid AND
817820
amopmethod = (SELECT oid FROM pg_am WHERE amname = 'btree')
818821
ORDER BY 1, 2;
819-
proname | oprname | amopstrategy
820-
---------+---------+--------------
821-
max | > | 5
822-
min | < | 1
823-
(2 rows)
822+
proname | oprname | amopstrategy
823+
----------+---------+--------------
824+
bool_and | < | 1
825+
bool_or | > | 5
826+
every | < | 1
827+
max | > | 5
828+
min | < | 1
829+
(5 rows)
824830

825831
-- Check that there are not aggregates with the same name and different
826832
-- numbers of arguments. While not technically wrong, we have a project policy

‎src/test/regress/sql/opr_sanity.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,12 @@ WHERE a.aggfnoid = p.oid AND
626626
NOT binary_coercible(p.proargtypes[0],a.aggtranstype);
627627

628628
-- Cross-check aggsortop (if present) against pg_operator.
629-
-- We expect to findonly "<"for"min" and ">" for "max".
629+
-- We expect to findentriesforbool_and, bool_or, every,max, and min.
630630

631631
SELECT DISTINCT proname, oprname
632632
FROM pg_operatorAS o, pg_aggregateAS a, pg_procAS p
633633
WHEREa.aggfnoid=p.oidANDa.aggsortop=o.oid
634-
ORDER BY1;
634+
ORDER BY1,2;
635635

636636
-- Check datatypes match
637637

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp