![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
That's very strange. |
#2
| |||
| |||
|
|
Hi, everybody! =20 I am getting some weird behaviour trying to use a partial index in 7.3: =20 testdb=3D# create table a (x int, y int, z int); CREATE testdb=3D# create index a_idx on a(x,y) where z is null; CREATE testdb=3D# create index b_idx on a (x,y); CREATE testdb=3D# explain select * from a where x=3D1 and y=3D2 and z is null; QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20 ---------------------------------------------------------------- Index Scan using b_idx on a (cost=3D0.00..4.83 rows=3D1 width=3D12) Index Cond: ((x =3D 1) AND (y =3D 2)) Filter: (z IS NULL) (3 rows) =20 =20 Any idea, why is it using b_idx with a filter, instead of going straight= =20 for a_idx? Another thing is, if I drop b_idx, it then starts using a_idx, but=20 *still* has that 'Filter:' thing in the query plan... I understand, that the latter doesn't hurt much... but the former=20 *does*, because in my "real life" app, (much) less then half of entries= =20 are non-null.... :-( =20 Thanks! =20 Dima =20 =20 =20 ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match |
|
"All that is needed for the forces of evil to triumph is for enough good men to do nothing." - Edmond Burke "The penalty good people pay for not being interested in politics is to be governed by people worse than themselves." - Plato |
![]() |
| Thread Tools | |
| Display Modes | |
| |