- Notifications
You must be signed in to change notification settings - Fork28
Commit5e09280
committed
Make pg_statistic and related code account more honestly for collations.
When we first put in collations support, we basically punted on teachingpg_statistic, ANALYZE, and the planner selectivity functions about that.They've just used DEFAULT_COLLATION_OID independently of the actualcollation of the data. It's time to improve that, so:* Add columns to pg_statistic that record the specific collation associatedwith each statistics slot.* Teach ANALYZE to use the column's actual collation when comparing valuesfor statistical purposes, and record this in the appropriate slot. (Notethat type-specific typanalyze functions are now expected to fillstats->stacoll with the appropriate collation, too.)* Teach assorted selectivity functions to use the actual collation ofthe stats they are looking at, instead of just assuming it'sDEFAULT_COLLATION_OID.This should give noticeably better results in selectivity estimates forcolumns with nondefault collations, at least for query clauses that usethat same collation (which would be the default behavior in most cases).It's still true that comparisons with explicit COLLATE clauses differentfrom the stored data's collation won't be well-estimated, but that's noworse than before. Also, this patch does make the first step towardsdoing better with that, which is that it's now theoretically possible tocollect stats for a collation other than the column's own collation.Patch by me; thanks to Peter Eisentraut for review.Discussion:https://postgr.es/m/14706.1544630227@sss.pgh.pa.us1 parent8fb569e commit5e09280
File tree
18 files changed
+189
-90
lines changed- doc/src/sgml
- src
- backend
- commands
- statistics
- tsearch
- utils
- adt
- cache
- include
- catalog
- commands
- statistics
- utils
18 files changed
+189
-90
lines changedLines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6394 | 6394 |
| |
6395 | 6395 |
| |
6396 | 6396 |
| |
| 6397 | + | |
| 6398 | + | |
| 6399 | + | |
| 6400 | + | |
| 6401 | + | |
| 6402 | + | |
| 6403 | + | |
| 6404 | + | |
| 6405 | + | |
| 6406 | + | |
| 6407 | + | |
| 6408 | + | |
6397 | 6409 |
| |
6398 | 6410 |
| |
6399 | 6411 |
| |
|
Lines changed: 22 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
904 | 904 |
| |
905 | 905 |
| |
906 | 906 |
| |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
907 | 917 |
| |
908 | 918 |
| |
909 | 919 |
| |
910 | 920 |
| |
911 | 921 |
| |
| 922 | + | |
912 | 923 |
| |
913 | 924 |
| |
914 | 925 |
| |
| |||
1553 | 1564 |
| |
1554 | 1565 |
| |
1555 | 1566 |
| |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
1556 | 1572 |
| |
1557 | 1573 |
| |
1558 | 1574 |
| |
| |||
1993 | 2009 |
| |
1994 | 2010 |
| |
1995 | 2011 |
| |
1996 |
| - | |
1997 | 2012 |
| |
1998 |
| - | |
| 2013 | + | |
1999 | 2014 |
| |
2000 | 2015 |
| |
2001 | 2016 |
| |
| |||
2202 | 2217 |
| |
2203 | 2218 |
| |
2204 | 2219 |
| |
| 2220 | + | |
2205 | 2221 |
| |
2206 | 2222 |
| |
2207 | 2223 |
| |
| |||
2273 | 2289 |
| |
2274 | 2290 |
| |
2275 | 2291 |
| |
2276 |
| - | |
2277 |
| - | |
| 2292 | + | |
2278 | 2293 |
| |
2279 | 2294 |
| |
2280 | 2295 |
| |
| |||
2567 | 2582 |
| |
2568 | 2583 |
| |
2569 | 2584 |
| |
| 2585 | + | |
2570 | 2586 |
| |
2571 | 2587 |
| |
2572 | 2588 |
| |
| |||
2682 | 2698 |
| |
2683 | 2699 |
| |
2684 | 2700 |
| |
| 2701 | + | |
2685 | 2702 |
| |
2686 | 2703 |
| |
2687 | 2704 |
| |
| |||
2725 | 2742 |
| |
2726 | 2743 |
| |
2727 | 2744 |
| |
| 2745 | + | |
2728 | 2746 |
| |
2729 | 2747 |
| |
2730 | 2748 |
| |
|
Lines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
252 | 252 |
| |
253 | 253 |
| |
254 | 254 |
| |
| 255 | + | |
| 256 | + | |
| 257 | + | |
255 | 258 |
| |
256 | 259 |
| |
257 | 260 |
| |
| |||
266 | 269 |
| |
267 | 270 |
| |
268 | 271 |
| |
269 |
| - | |
| 272 | + | |
270 | 273 |
| |
271 | 274 |
| |
272 | 275 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
363 | 363 |
| |
364 | 364 |
| |
365 | 365 |
| |
366 |
| - | |
| 366 | + | |
367 | 367 |
| |
368 | 368 |
| |
369 | 369 |
| |
370 |
| - | |
| 370 | + | |
| 371 | + | |
371 | 372 |
| |
372 | 373 |
| |
373 | 374 |
| |
374 | 375 |
| |
375 |
| - | |
| 376 | + | |
376 | 377 |
| |
377 |
| - | |
378 | 378 |
| |
379 | 379 |
| |
380 | 380 |
| |
|
Lines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
454 | 454 |
| |
455 | 455 |
| |
456 | 456 |
| |
| 457 | + | |
| 458 | + | |
| 459 | + | |
457 | 460 |
| |
458 | 461 |
| |
459 | 462 |
| |
| |||
466 | 469 |
| |
467 | 470 |
| |
468 | 471 |
| |
469 |
| - | |
| 472 | + | |
470 | 473 |
| |
471 | 474 |
| |
472 | 475 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
| 17 | + | |
17 | 18 |
| |
18 | 19 |
| |
19 | 20 |
| |
| |||
415 | 416 |
| |
416 | 417 |
| |
417 | 418 |
| |
| 419 | + | |
418 | 420 |
| |
419 | 421 |
| |
420 | 422 |
| |
|
0 commit comments
Comments
(0)