forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0ee5a39
committed
Apply a band-aid fix for the problem that 8.2 and up completely misestimate
the number of rows likely to be produced by a query such asSELECT * FROM t1 LEFT JOIN t2 USING (key) WHERE t2.key IS NULL;What this is doing is selecting for t1 rows with no match in t2, and thusit may produce a significant number of rows even if the t2.key table columncontains no nulls at all. 8.2 thinks the table column's null fraction isrelevant and thus may estimate no rows out, which results in terrible plansif there are more joins above this one. A proper fix for this will involvepassing much more information about the context of a clause to the selectivityestimator functions than we ever have. There's no time left to write such apatch for 8.3, and it wouldn't be back-patchable into 8.2 anyway. Instead,put in an ad-hoc test to defeat the normal table-stats-based estimation whenan IS NULL test is evaluated at an outer join, and just use a constantestimate instead --- I went with 0.5 for lack of a better idea. This won'tcatch every case but it will catch the typical ways of writing such queries,and it seems unlikely to make things worse for other queries.1 parenta55eab8 commit0ee5a39
File tree
3 files changed
+23
-7
lines changed- src
- backend
- optimizer/path
- utils/adt
- include/utils
3 files changed
+23
-7
lines changedLines changed: 6 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
219 | 219 |
| |
220 | 220 |
| |
221 | 221 |
| |
222 |
| - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
223 | 225 |
| |
224 | 226 |
| |
225 | 227 |
| |
| |||
702 | 704 |
| |
703 | 705 |
| |
704 | 706 |
| |
705 |
| - | |
| 707 | + | |
| 708 | + | |
706 | 709 |
| |
707 | 710 |
| |
708 | 711 |
| |
|
Lines changed: 15 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
18 |
| - | |
| 18 | + | |
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
| |||
1385 | 1385 |
| |
1386 | 1386 |
| |
1387 | 1387 |
| |
1388 |
| - | |
| 1388 | + | |
1389 | 1389 |
| |
1390 | 1390 |
| |
1391 | 1391 |
| |
1392 | 1392 |
| |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
1393 | 1406 |
| |
1394 | 1407 |
| |
1395 | 1408 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
149 | 149 |
| |
150 | 150 |
| |
151 | 151 |
| |
152 |
| - | |
| 152 | + | |
153 | 153 |
| |
154 | 154 |
| |
155 | 155 |
| |
|
0 commit comments
Comments
(0)