× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi all, I'm talking about embedded SQL.

execute the following code 1.260 times:

EXEC SQL
DECLARE Curs3 CURSOR FOR SELECT
SUM(CASE WHEN lgtipo = 'I' THEN 1 ELSE 0 END),
SUM(CASE WHEN lgtipo = 'C' THEN 1 ELSE 0 END)
FROM mulettu00f
JOIN multtt100f ON lcidlettur = l1idlettur AND l1statorec = ' '
JOIN multtt400f ON L1ID = lgidl1 AND LGSTATOREC = ' '
AND LGTIPO IN ('I', 'C')
WHERE LcCDUTENTE = :ABCDUTENTE
AND lcstatorec = ' '
AND YEAR(lcdatalett) = 2024
AND lctipolett = 'S';
...

EXEC SQL OPEN Curs3;
EXEC SQL FETCH Curs3 INTO :nI :iI, :nC :iC;
...
EXEC SQL CLOSE Curs3;

Takes 2/3 seconds.

Executing 1.260 times any variation of these 4 statements (the last one is
the cursor's code):

EXEC SQL SELECT SUM(CASE WHEN lgtipo = 'I' THEN 1 ELSE 0 END),
SUM(CASE WHEN lgtipo = 'C' THEN 1 ELSE 0 END)
INTO :nI , :nC
FROM multtt400f WHERE lgidl1 IN (SELECT L1ID FROM multtt100f
WHERE l1idlettur IN (SELECT lcidlettur FROM mulettu00f
WHERE LcCDUTENTE = :abcdutente AND lcstatorec = ' '
AND YEAR(lcdatalett) = 2024 AND lctipolett = 'S')
AND l1statorec = ' ') AND LGSTATOREC = ' '
AND LGTIPO IN ('I', 'C');

EXEC SQL SELECT SUM(CASE WHEN lgtipo = 'I' THEN 1 ELSE 0 END),
SUM(CASE WHEN lgtipo = 'C' THEN 1 ELSE 0 END)
INTO :nI :iI, :nC :iC
FROM multtt400f
JOIN multtt100f ON lgidl1 = L1ID
JOIN mulettu00f ON l1idlettur = lcidlettur
WHERE LGSTATOREC = ' '
AND LGTIPO IN ('I', 'C')
AND l1statorec = ' '
AND LcCDUTENTE = :ABCDUTENTE
AND lcstatorec = ' '
AND YEAR(lcdatalett) = 2024
AND lctipolett = 'S';

EXEC SQL SELECT SUM(CASE WHEN lgtipo = 'I' THEN 1 ELSE 0 END),
SUM(CASE WHEN lgtipo = 'C' THEN 1 ELSE 0 END)
INTO :nI :iI, :nC :iC
FROM mulettu00f
JOIN multtt100f ON lcidlettur = l1idlettur
JOIN multtt400f ON L1ID = lgidl1
WHERE LGSTATOREC = ' '
AND LGTIPO IN ('I', 'C')
AND l1statorec = ' '
AND LcCDUTENTE = :ABCDUTENTE
AND lcstatorec = ' '
AND YEAR(lcdatalett) = 2024
AND lctipolett = 'S';

EXEC SQL SELECT SUM(CASE WHEN lgtipo = 'I' THEN 1 ELSE 0 END),
SUM(CASE WHEN lgtipo = 'C' THEN 1 ELSE 0 END)
INTO :nI :iI, :nC :iC
FROM mulettu00f
JOIN multtt100f ON lcidlettur = l1idlettur AND l1statorec = ' '
JOIN multtt400f ON L1ID = lgidl1 AND LGSTATOREC = ' '
AND LGTIPO IN ('I', 'C')
WHERE LcCDUTENTE = :ABCDUTENTE
AND lcstatorec = ' '
AND YEAR(lcdatalett) = 2024
AND lctipolett = 'S';

Takes 20 minutes.

Is there something obvious I'm not seeing? Or is such a big difference
normal?

TIA
--
Marco Facchinetti

Mr S.r.l.

Tel. 035 962885
Cel. 393 9620498

Skype: facchinettimarco

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.