[postgis-users] Why won’t my SELECT query use the INDEX?

2014-12-16 Thread CABO
This seems like one of the most asked questions in the PostgreSQL world, but I guess I haven’t understood all the answers yet: Why won’t my SELECT query use the INDEX I have created for it? I have a table with about 18mio rows. My SELECT statement looks like this: SELECT

Re: [postgis-users] Why won’t my SELECT query use the INDEX?

2014-12-16 Thread Andy Colson
On 12/16/2014 9:18 AM, Casper Børgesen (CABO) wrote: This seems like one of the most asked questions in the PostgreSQL world, but I guess I haven’t understood all the answers yet: Why won’t my SELECT query use the INDEX I have created for it? I have a table with about 18mio rows. My SELECT

Re: [postgis-users] Why won’t my SELECT query use the INDEX?

2014-12-16 Thread Rémi Cura
Hey, no index can come from 2 problems : - your querry can't use the index - your querry could use the index but the planner thinks it's faster to do sequential scan. You can discriminate between the 2 avoiding explicitly sequential scan : `SET enable_seqscan TO FALSE` (don't forget to turn

Re: [postgis-users] Why won’t my SELECT query use the INDEX?

2014-12-16 Thread Rémi Cura
For this particular case, using st_srid(geom) means that the planner have to compute this value for each line . (the planner has no way to know that srid is the same for every geometry in the column, this might not be the case) You can't use it . for instance, you could simply use plpgsql to get