Postgres combining multiple Indexes

前端 未结 2 1560
别那么骄傲
别那么骄傲 2021-02-06 09:58

I have the following table/indexes -

CREATE TABLE test
(
   coords geography(Point,4326), 
   user_id varchar(50), 
   created_at timestamp
);
CREATE INDEX ix_co         


        
2条回答
  •  不要未来只要你来
    2021-02-06 10:39

    I think Craig is correct with his answer, but I just wanted to add a few things (and it wouldn't fit in a comment)

    You have to work pretty hard to force PostgreSQL to use an index. The Query optimizer is smart and there are times where it will believe that a sequential table scan will be faster. It is usually right! :) But, you can play with some settings (such as seq_page_cost, random_page_cost, etc) you can play with to try and get it to favor an index. Here is a link to some of the configurations that you might want to examine if you feel like it is not making the correct decision. But, again... my experience is that most of the time, Postgres is smarter than I am! :)

    Hope this helps you (or someone in the future).

提交回复
热议问题