Re: view or index to optimize performance
От | Richard Huxton |
---|---|
Тема | Re: view or index to optimize performance |
Дата | |
Msg-id | 43AA53DA.7010700@archonet.com обсуждение исходный текст |
Ответ на | view or index to optimize performance (Klein Balázs <Balazs.Klein@axelero.hu>) |
Список | pgsql-general |
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
В списке pgsql-general по дате отправления: