O'Reilly logo

PostGIS Cookbook by Bborie Park, Stephen Vincent Mather, Thomas J. Kraft, Paolo Corti

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Optimizing SQL queries

When a SQL query is received, PostgreSQL runs the query through its planner to decide the best execution plan. The best execution plan generally results in the fastest query performance. Though the planner usually makes the correct choices, on occasion, a specific query will have a suboptimal execution plan.

For these situations, the following are several things that can be done to change the behavior of the PostgreSQL planner:

  • Add appropriate column indexes to the tables in question
  • Update the statistics of the database tables
  • Rewrite the SQL query by evaluating the query's execution plan and using capabilities available in your PostgreSQL installation
  • Consider changing or adding to the layout of the database tables
  • Change the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required