Unix Technical Forum

showplan results in esql/c

This is a discussion on showplan results in esql/c within the Sybase forums, part of the Database Server Software category; --> Hallo, we have performance problems with an esql/c program. The select via isql works fine and is fast but ...


Go Back   Unix Technical Forum > Database Server Software > Sybase

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 04:07 PM
J. Bajdala
 
Posts: n/a
Default showplan results in esql/c

Hallo,

we have performance problems with an
esql/c program.

The select via isql works fine and is
fast but takes some minutes in the esql/c
program.

I think it's possible to activate
"set showplan on" via "exec sql".

But how do I get the text of the
execution plan?

Rega

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 04:07 PM
Ibrahim DOGAN
 
Posts: n/a
Default Re: showplan results in esql/c

> The select via isql works fine and is
> fast but takes some minutes in the esql/c
> program.


Make sure you're running *identical* sql in isql and esql/c.
esql/c might be using different datatype in WHERE clause than indexed
column(s) that causes tablescan.

i.d.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 04:07 PM
Mariano Corral
 
Posts: n/a
Default Re: showplan results in esql/c

I'm not sure if it's possible to print the "showplan"
as an ESQL program runs. If not, there are other
things you can do, such as running
sp_showplan <spid>, NULL, NULL, NULL
as the program executes. Unfortunately, this only
shows the execution plan for INSERT, UPDATE,
DELETE and plain SELECT, not ESQL cursors, where
sp_showplan only shows the cursor name.

If the ESQL program executes SQL with slower
performance than isql, check the common causes for
this:
- Add "FOR READ ONLY" in every non-updateable cursor.
Otherwise, ASE will asume it is a cursor for update
and choose a unique index, even if there is
a more performant non-unique index
- Check datatype mismatch. IIRC, differences in the
length of char variables are handled OK by ESQL,
but this is not the case with numbers; mismatchs
between int and float, for instance, may prevent
ASE from choosing an index.
- In very rare cases, cursors behave differently
than plain selects. If in doubt, check if isql
shows the same showplan for a SELECT and its
corresponding OPEN cursor.
For instance, cursors cannot use the "OR
strategy" (not the same as the "special OR
strategy", which cursors can use)
- The optimizer uses different statistics if the
value of a column is known or not. If in doubt,
check if isql shows the same showplan for both;
for instance,
WHERE COL1 = 7
versus
WHERE COL1 = @local_variable

Regards,
Mariano Corral

"J. Bajdala" <baj@sisis.de> wrote:
> we have performance problems with an
> esql/c program.
>
> The select via isql works fine and is
> fast but takes some minutes in the esql/c
> program.
>
> I think it's possible to activate
> "set showplan on" via "exec sql".
>
> But how do I get the text of the
> execution plan?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-08-2008, 04:08 PM
J. Bajdala
 
Posts: n/a
Default Re: showplan results in esql/c

Mariano Corral wrote:

> I'm not sure if it's possible to print the "showplan"
> as an ESQL program runs. If not, there are other
> things you can do, such as running
> sp_showplan <spid>, NULL, NULL, NULL


Thanks for the hints.

I checked them (especially the cursor and
variable hint) but the execution plan was
ok.

We then tested our program at a big customer
database - the performance was fine there.

Since this program shall run only once
(at different customers db's of course)
we hope this was a special problem at our
database and hope the best for our customers :-)

Regards

Jürgen

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:38 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com