patternsqlMinor
Is the speed of a PostgreSQL SELECT adversely affected by too many indexes on the table?
Viewed 0 times
postgresqlthetooindexesaffectedmanyselectadverselyspeedtable
Problem
I have read that when having a lot of indexes on a database It can seriously hurt the performance but in the PostgreSQL doc I can't find anything about it.
I have a very big table with something like 100 columns and a billion rows and often I have to do a lot of searches in a lot of different fields.
Does the performance of the PostgreSQL table will drop if I add a lot of indexes (maybe 10 unique column indexes and 5 to 7 three column indexes)?
EDIT: With performance drop I mean
I have a very big table with something like 100 columns and a billion rows and often I have to do a lot of searches in a lot of different fields.
Does the performance of the PostgreSQL table will drop if I add a lot of indexes (maybe 10 unique column indexes and 5 to 7 three column indexes)?
EDIT: With performance drop I mean
SELECT performance; the database will only be updated once per month so UPDATE and INSERT speed is not an issue.Solution
No, the query performance will not be affected, or not very much. Indexes are updated on DML statements (and
The decision whether they will be used are made by the planner. With very many indexes present I can imagine that the planner spends more time on choosing the usable ones, but I would expect the difference to be small. (Normally, planning is faster that retrieving rows.)
Note that usually a few indexes will speed up a lot of different queries. This may not be the case if you filter on many of your columns.
Also note that in a lot of cases (and without knowing your table definition one cannot decide whether your case falls into 'most' or not) having so many columns reflects having a less-that-optimal schema design.
TRUNCATE) while they may or may not be used when executing a query.The decision whether they will be used are made by the planner. With very many indexes present I can imagine that the planner spends more time on choosing the usable ones, but I would expect the difference to be small. (Normally, planning is faster that retrieving rows.)
Note that usually a few indexes will speed up a lot of different queries. This may not be the case if you filter on many of your columns.
Also note that in a lot of cases (and without knowing your table definition one cannot decide whether your case falls into 'most' or not) having so many columns reflects having a less-that-optimal schema design.
Context
StackExchange Database Administrators Q#25449, answer score: 6
Revisions (0)
No revisions yet.