How can I check if my cursor statement is using index

Started by Dragan Maticover 20 years ago3 messagesgeneral
Jump to latest
#1Dragan Matic
mlists@panforma.co.yu

I have a program that reads data from Postgresql database (version
8.0.3) through ODBC, but data retrieval is pretty slow. When I type the
same SQL sentence in pgadmin III or any other sql tool it is much
faster, and typing 'explain' clearly shows that it is using index.
However the program is reading data through a dynamic cursor, I would
like to know if there is a way to check if the same sql query generated
through dynamic cursor still uses indexes?
Thanks in advance

Dragan

#2Dragan Matic
mlists@panforma.co.yu
In reply to: Dragan Matic (#1)
Re: How can I check if my cursor statement is using index

Dragan Matić wrote:

I have a program that reads data from Postgresql database (version
8.0.3) through ODBC, but data retrieval is pretty slow. When I type
the same SQL sentence in pgadmin III or any other sql tool it is much
faster, and typing 'explain' clearly shows that it is using index.
However the program is reading data through a dynamic cursor, I would
like to know if there is a way to check if the same sql query
generated through dynamic cursor still uses indexes?
Thanks in advance

Dragan

Another thing i've noticed is that if I open a simple cursor it
definitely uses index as data is retrieved instantly as opposed to 2-3
seconds when I try to retrieve data through a dynamic cursor. Is there a
way to force index usage through a dynamic cursor?

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dragan Matic (#1)
Re: How can I check if my cursor statement is using index

=?UTF-8?B?RHJhZ2FuIE1hdGnEhw==?= <mlists@panforma.co.yu> writes:

I have a program that reads data from Postgresql database (version
8.0.3) through ODBC, but data retrieval is pretty slow. When I type the
same SQL sentence in pgadmin III or any other sql tool it is much
faster, and typing 'explain' clearly shows that it is using index.
However the program is reading data through a dynamic cursor, I would
like to know if there is a way to check if the same sql query generated
through dynamic cursor still uses indexes?

Try EXPLAIN DECLARE x CURSOR FOR ...

regards, tom lane