title: GIST Index Expression based on Geography Type Column Problems
body: <p>I have question about how postgresql use indexes. I have problems with Gist Index Expression based on Geography Type Column in Postgresql with Postgis enabled database.</p>
  
  <p>I have the following table:</p>
  
  <pre><code>CREATE TABLE place
  (
    id serial NOT NULL,
    name character varying(40) NOT NULL,
    location geography(Point,4326),
    CONSTRAINT place_pkey PRIMARY KEY (id )
  )
  </code></pre>
  
  <p>Then I created Gist Index Expression based on column "location"</p>
  
  <pre><code>CREATE INDEX place_buffer_5000m ON place
  USING GIST (ST_BUFFER(location, 5000));
  </code></pre>
  
  <p>Now suppose that in table route I have column shape with Linestring object and I want to check which 5000m polygons (around the location) the line crosses.</p>
  
  <p>The query below in my opinion shoud use the "place_buffer_5000m" index but does not use it.</p>
  
  <pre><code>SELECT place.name
  FROM place, route
  WHERE
    route.id=1 AND
    ST_CROSSES(route.shape::geometry, ST_BUFFER(place.location, 5000)::geometry))
  </code></pre>
  
  <p>Table place have about 76000 rows. Analyze and Vacuum was run on this table with recreating "place_buffer_5000m" index but the index is not used during the above query.</p>
  
  <p>What is funny when I create another column in table place named "area_5000m" (geograpthy type) and update the table like:</p>
  
  <pre><code>UPDATE place SET area_5000m=ST_BUFFER(location, 5000)
  </code></pre>
  
  <p>And then create gist index for this column like this:</p>
  
  <pre><code>CREATE INDEX place_area_5000m ON place USING GIST (area_5000m)
  </code></pre>
  
  <p>Then using the query:</p>
  
  <pre><code>SELECT place.name
  FROM place, route
  WHERE
    route.id=1 AND
    ST_CROSSES(route.shape::geometry, place.area_5000m::geometry))
  </code></pre>
  
  <p>The index "place_area_5000m" is used.
  The question is why the Index expression that is calculated based on location column is not used?</p>