English 中文(简体)
Is it possible to return a list of numbers from a Sybase function?
原标题:

I m trying to overcome a very serious performance issue in which Sybase refuses to use the primary key index on a large table because one of the required fields is specified indirectly through another table - or, in other words;

SELECT ... FROM BIGTABLE WHERE KFIELD = 123

runs in ms but

SELECT ... FROM BIGTABLE, LTLTBL WHERE KFIELD = LTLTBL.LOOKUP 
   AND LTLTBL.UNIQUEID =  STRINGREPOF123 

takes 30 - 40 seconds.

I ve managed to work around this first problem by using a function that basically lets me do this;

SELECT ... FROM BIGTABLE WHERE KFIELD = MYFUNC( STRINGREPOF123 )

which also runs in ms.

The problem, however, is that this approach only works when there is a single value returned by MYFUNCT but I have some cases where it may return 2 or 3 values.

I know that the SQL

SELECT ... FROM BIGTABLE WHERE KFIELD IN (123,456,789)

also returns in milliseconds so I d like to have a function that returns a list of possible values rather than just a single one - is this possible?

Sadly the application is running on Sybase ASA 9. Yes I know it is old and is scheduled to be refreshed but there s nothing I can do about it now so I need logic that will work with this version of the DB.

问题回答

What about using a temporary table to store your numbers? So your sql would look like this:

    select kfield into #tmpKfield 
    from littleTable 
    where UNIQUEID =  STRINGREPOF123 

    select * from bigTable 
    where kfield in (select kfield from #tmpKfield)
    go

    drop table #tmpKfield
    go

That is how I try to solve your issue.





相关问题
What to look for in performance analyzer in VS 2008

What to look for in performance analyzer in VS 2008 I am using VS Team system and got the performance wizard and reports going. What benchmarks/process do I use? There is a lot of stuff in the ...

SQL Table Size And Query Performance

We have a number of items coming in from a web service; each item containing an unknown number of properties. We are storing them in a database with the following Schema. Items - ItemID - ...

How to speed up Visual Studio 2008? Add more resources?

I m using Visual Studio 2008 (with the latest service pack) I also have ReSharper 4.5 installed. ReSharper Code analysis/ scan is turned off. OS: Windows 7 Enterprise Edition It takes me a long time ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

热门标签