Search Postgresql Archives

Re: view or index to optimize performance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Klein Balázs wrote:
Hello everybody,

I have a table that stores responses to questions in different
questionnaires. This table will grow to millions of rows.
[snip]
I can store the fact that it is biodata in the bio field - it is biodata if
the value of that field is not 0 and I can index that field and simply use
that as one of the conditions in queries.

Or should I instead create a view that contains only the biodata and select
from that? But will postgres use the indexes than? Would that be a better
approach?

Create the index on the table and a view should use it.

You might like to read up on partial indexes where you can do something like:

CREATE INDEX my_index ON itemresponse (testoccasionid,itemorder)
WHERE bio > 0;

So long as your query/view definition has WHERE bio > 0 in it then this index can be used.

HTH
--
  Richard Huxton
  Archonet Ltd



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux