简体   繁体   中英

is there a way to improve the speed of the ODBC connection between sql server and DB2?

I ran this query on my sql server

SELECT A.[STCOMP]
    ,A.[STDATE]
    ,A.[STUNM]
    ,A.[STQTY]
    ,A.[STWWAY]
    ,A.[STVOID]
    ,A.[STMATR]
    ,A.[STTCKT]
    ,C.[RWDESC]
    ,A.[STDESC]
    ,A.[STLNDF]
    ,B.[CSLNAM]
    ,B.[CBLNAM]
    ,D.[CVAR6]
FROM [EPAK].[B00BF4CR].[IWSE4S8].[SCTRN] AS A
INNER JOIN [EPAK].[B00BF4CR].[IWSE4S8].[CUST] AS B ON A.[STNCST] = B.[CMSTC#]
    AND A.[STNCMP] = B.[CMSTCO]
    AND A.[STCOMP] = B.[CCMPNY]
    AND A.[STCUST] = B.[CCUST#]
INNER JOIN [EPAK].[B00BF4CR].[IWSE4S8].[SCRWC] AS C ON C.[RWRESW] = A.[STRWC]
    AND C.[RWCOMP] = A.[STCOMP]
INNER JOIN [EPAK].[B00BF4CR].[IWSE4S8].[CUSX] AS D ON A.[STCOMP] = D.[CCMPNY]
    AND A.[STCUST] = D.[CCUST#]
WHERE (
        A.[STDATE] = 20140211
        AND A.[STVOID] = 'N'
        )
ORDER BY A.[STTCKT]

the data is for one day only, it returned me 3000 records, but took 52 minutes to do that. That query is pulling data between a linked DB2 server using odbc connection and my sql.

You can create a view in DB2 in which includes all the joins and selections.

You then simply query this view over the ODBC connection.

The problem is that the ODBC link is very slow, and, returns one row at a time. You should do everything you can to minimize the amount of data that is sent over the link.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM