I have a simple query to join two tables that\'s being really slow. I found out that the query plan does a seq scan on the large table email_activities (~10m ro
A sequential scan can be more efficient, even when an index exists. In this case, postgres seems to estimate things rather wrong.
An ANALYZE on all related tables can help in such cases. If it doesnt, you can set the variable
enable_seqscan to OFF, to force postgres to use an index whenever technically possible, at the expense, that sometimes an index-scan will be used when a sequential scan would perform better.