Mihail Nasedkin wrote:
RH> Why do you want an index scan? Do you have any evidence it will be RH> faster than a sequential scan?
No, but I want to be ready for make Index scan queries in future. I make first steps on the customize SQL.
PostgreSQL uses statistics on what values are in what columns to decide how to plan a query. So - if you are asking for all rows from a table it probably won't use an index because it knows you will have to read the whole table anyway.
Where I can read more about optimize the SQL-queries and about differences between types of scan?
Well, perhaps the best place to learn more is the performance mailing list. You can see plenty of real-world problems being discussed there.
Two sections of the manual you should read are
Chapter 13. Performance Tips
Chapter 23. Monitoring Database Activity
Understanding how to read EXPLAIN ANALYSE output and manage statistics are vital.
Finally, details on configuration settings can be found at: http://www.powerpostgresql.com/PerfList http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php
-- Richard Huxton Archonet Ltd
---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match