"bharat u" <bharatupc@gmail.com> writes:
> Can anyone tell me how pg_analyze_and_rewrite works?
That's a rather broad question. Have you read the overview in the manual?
http://developer.postgresql.org/pgdocs/postgres/overview.html
pg_analyze_and_rewrite covers what that material calls the
"transformation process" and "query rewrite" stages of processing.
If you've got specific questions about pieces of that code,
pgsql-hackers is probably a better place than -general for asking 'em.
regards, tom lane