|
|||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
Neil Conway gave a talk on the internals of the PostgreSQL Query Optimizer at linux.conf.au this month. He has made the slides available and encourages Corrections or suggestions for improvement. The material is in the public domain. This is an excellent presentation of what the PostgreSQL optimizer is and how it works. This is the best English explanation I've seen or heard of the optimizer. Neil's text validates and enhances the understanding I have had with regards to the inner workings of the optimizer without adding to the confusion possible when describing a complex system. Understanding the optimizer is important in order to tune queries. But the contradiction is that a very good optimizer, as ours is, should probably not be second guessed often. Yet we all want to do so. Neil only touches on techniques to give direction to the optimizer, but the focus of the presentation is to describe the optimizer.
You can use the options of pg_dump to see the specific
Data Definition Language (DDL) used to define tables.
The command The original question in this thread was how to show this DDL in psql. The answer, of course, is to execute a shell command from the psql prompt. db=>\! pg_dump -s -t detail_order elein
A pg_dump file used for upgrades sometimes can be difficult if it is big and when the schema and/or application changes at the same time. In these cases it is helpful to track the ERROR messages from psql in a separate file so that many errors can be sorted out and corrected at once. To do this we use the appropriate shell commands. For example: zcat cli_postDataInserts.sql.gz | psql -d cli_post -U system --echo-queries -f - >trace.file 2>&1 In this command we unzip the dump file and pipe it into psql into the database cli_post with the user system. Catching only the error message without context is not really very helpful so we add the flag --echo-queries. The -f flag sends the output to a file, in this case standard out with is signified with a dash -. Standard out (>) is redirected to the file called trace.file and standard error (2>) is redirected to the file pointer for standard in (&1). You can use variations of the standard error and standard output to catch different output from psql. Just remember than the ERROR statements go to standard out.
|
|||||||||||||||
Comments and Corrections are welcome. Suggestions and contributions of items are also welcome. Send them in! Copyright A. Elein Mustain 2003, 2004, 2005, 2006, 2007, 2008, 2009 |