On Sun, Mar 12, 2006 at 02:16:50PM +0800, Syan Tan wrote: > I did try that , but in postgresql.conf and it didn't seem to work. perhaps > if I > insert set enable_seqscan=off in the session , it will be the same, in which > case , you > do not have to change the sql. I'll verify it saves time as well. Yes, please do. Note, however, that this is a better fix (because it is closer to the real solution) but far from the proper one.
One thing you should definitely try, too, is to run "vacuum analyze" on the database after insertion of your large test dataset. See, the real reason (unless there is a bug) why the query planner chooses a seq scan over an index scan is that the planner thinks the seq scan is going to be faster ! Which is very true in the initial database state where most tables are nearly empty. The planner uses table statistics to decide whether seq or idx scans should be better. These statistics need to be updated after significant changes to table data. Else the planner will work with false assumptions leading it to choose seq scans over index scans. I do believe updating the statistics will make the planner use the indexes without any need for changing the sql or disallowing seq scans entirely... The test I did with "set enable_seqscan to off" was simply to prove that the query planner technically *can* use indexes on child tables. Karsten -- GPG key ID E4071346 @ wwwkeys.pgp.net E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346 _______________________________________________ Gnumed-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/gnumed-devel
