|
Home > Archive > PostgreSQL Discussion > September 2005 > How can I check if my cursor statement is using index
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How can I check if my cursor statement is using index
|
|
| Dragan Matić 2005-09-29, 3:23 am |
| 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
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
| |
| Dragan Matić 2005-09-29, 3:23 am |
| 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?
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
| |
| Tom Lane 2005-09-29, 11:23 am |
| =?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
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend
|
|
|
|
|