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


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

              http://www.postgresql.org/docs/faq

Reply via email to