473,626 Members | 3,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

poor query performance

Ion
Hi all,

I have a query that takes almost 1 hour to complete. This is acceptable
in certain situations, but unacceptable when no rows should qualify.

Something like:

Select list
From LargeTable (200 mil rows)

Join ExpensiveTableF unction (based on LargeTable)
ON simple_join_con dition
JOIN SmallTable ON simple_join_con dition
WHERE BitAND(SmallTab le.Coulmn, 2) <> 0

The SmallTable table has exactly 2 rows, and neither of them passes the
where clause predicate.
If I could make the optimizer to somehow evaluate first the WHERE
clause the query would be fast - as no row qualifies.

Running statistics, rewriting the query in 1 million ways didn't help,
is there any way to trick the optimizer?

I use DB2 8.2 UDB Windows FP8

thanks

Nov 12 '05 #1
7 2870
Ion wrote:
Hi all,

I have a query that takes almost 1 hour to complete. This is acceptable
in certain situations, but unacceptable when no rows should qualify.

Something like:

Select list
From LargeTable (200 mil rows)

Join ExpensiveTableF unction (based on LargeTable)
ON simple_join_con dition
JOIN SmallTable ON simple_join_con dition
WHERE BitAND(SmallTab le.Coulmn, 2) <> 0

The SmallTable table has exactly 2 rows, and neither of them passes the
where clause predicate.
If I could make the optimizer to somehow evaluate first the WHERE
clause the query would be fast - as no row qualifies.

Running statistics, rewriting the query in 1 million ways didn't help,
is there any way to trick the optimizer?

I use DB2 8.2 UDB Windows FP8


It would help if you gave a few examples that show what you actually have
tried already. Have you tried the following queries?

SELECT list
FROM ( SELECT ...
FROM small-table
WHERE BitAND(small-table.column, 2) <> 0 ) JOIN
( large-table JOIN table-function ON condition ) ON condition

Or wrap the sub-select in a common table expression to force its evaluation
right up front.

Another idea might be to use generated columns for the BitAND() function
call. Then the optimizer could re-route to that column and, with
statistics on that column, figure out right away if and how many columns
qualify.

--
Knut Stolze
Information Integration Development
IBM Germany / University of Jena
Nov 12 '05 #2
Ion
Hi Knut,

Yes, I have tired both the common table expression and it did not seem
to force it's evaluation first, as well as the query you suggested.
Adding a column is not an option.
As the select query happens in a stored procedure I can't think of
anything else than maybe using a temp table.
Thanks for your suggestions

Nov 12 '05 #3
Can you separately query the small table and use a "found rows" type
condition to then execute the query. This would completely avoid the
long running query when there are no matching rows in SmallTable.

You might also try replicating the WHERE predicate as part of the ON
predicate for the join to SmallTable. Use EXPLAIN to see if it makes a
difference. If a very small number of rows from Large Table match the
rows in SmallTable then using an IN clause with a subselect on
SmallTable to limit rows from LargeTable may help the optimizer evaluate
SmallTable first.

If you don't have an index on the LargeTable columns that match
SmallTable, you'll be forced into a scan to locate the matching rows. As
mentioned by Knut, statistics are necessary for the optimizer to make
better choices.

Phil Sherman

Ion wrote:
Hi Knut,

Yes, I have tired both the common table expression and it did not seem
to force it's evaluation first, as well as the query you suggested.
Adding a column is not an option.
As the select query happens in a stored procedure I can't think of
anything else than maybe using a temp table.
Thanks for your suggestions

Nov 12 '05 #4
Ion wrote:
Hi Knut,

Yes, I have tired both the common table expression and it did not seem
to force it's evaluation first, as well as the query you suggested.
Adding a column is not an option.
As the select query happens in a stored procedure I can't think of
anything else than maybe using a temp table.
Thanks for your suggestions

How is BITAND defined? If it's an external UDF, then make suer it's
defined as NO EXTERNAL ACTION otherwise DB2 can push the predicate.
Also once the UDF is tested sufficiently define it as UNFENCED, so it
runs in DB2's process space.
Otherwise I supect you used an SQL Function. How is is defined?

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #5
Ion wrote:
Adding a column is not an option.
Why not? Could you please explain the reason for the restriction?
As the select query happens in a stored procedure I can't think of
anything else than maybe using a temp table.


Have a look at the access plan. It should show if and where a temp table is
to be used.

--
Knut Stolze
Information Integration Development
IBM Germany / University of Jena
Nov 12 '05 #6
Ion
It's a SQL function (the one posted on the ibm support site) and it's
declared as
LANGUAGE SQL
CONTAINS SQL
NO EXTERNAL ACTION
DETERMINISTIC

Some more details:
Large_table is joined with SmallTable on an INT column. The 2 rows in
SmallTable have a value of 1 and 0 for the join column.
99% of the rows in LargeTable have the value 1 for the join column.
Even getting rid of the BitAND function and replacing the Where
BitAND(SmallTab le.Coulmn, 2) <> 0 WITH WHERE SmallTable.Coul mn<0, will
still not persuate the optimizer to evaluate this predicate first
(detailed and distribution statistics collected on all columns of Small
table)

Nov 12 '05 #7
Ion wrote:
It's a SQL function (the one posted on the ibm support site) and it's
declared as
LANGUAGE SQL
CONTAINS SQL
NO EXTERNAL ACTION
DETERMINISTIC

Some more details:
Large_table is joined with SmallTable on an INT column. The 2 rows in
SmallTable have a value of 1 and 0 for the join column.
99% of the rows in LargeTable have the value 1 for the join column.
Even getting rid of the BitAND function and replacing the Where
BitAND(SmallTab le.Coulmn, 2) <> 0 WITH WHERE SmallTable.Coul mn<0, will
still not persuate the optimizer to evaluate this predicate first
(detailed and distribution statistics collected on all columns of Small
table)

May be the function is too complex (inlcudes BEGIN TOMIC .. END) and
prevents some rewrite rules (e.g. pushdowns).
Here is soem source I wrote a while ago which uses C, as always no
warranty in thsi group ... :-)

udfbit.c:
/*************** *************** *************** *************** *************** *
** Written by Serge Rielau
*************** *************** *************** *************** *************** */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sqlca.h>
#include <sqludf.h>

#ifdef __cplusplus
extern "C"
#endif
void SQL_API_FN Bit_And(SQLUDF_ BIGINT *number1,
SQLUDF_BIGINT *number2,
SQLUDF_BIGINT *outNumber,
SQLUDF_SMALLINT *number1NullInd ,
SQLUDF_SMALLINT *number2NullInd ,
SQLUDF_SMALLINT *outNumberNullI nd,
SQLUDF_TRAIL_AR GS)
{
if (*number1NullIn d == -1 || *number2NullInd == -1)
{
*outNumberNullI nd = -1;
}
else
{
*outNumber = *number1 & *number2;
*outNumberNullI nd = 0;
}
}

#ifdef __cplusplus
extern "C"
#endif
void SQL_API_FN Bit_Or(SQLUDF_B IGINT *number1,
SQLUDF_BIGINT *number2,
SQLUDF_BIGINT *outNumber,
SQLUDF_SMALLINT *number1NullInd ,
SQLUDF_SMALLINT *number2NullInd ,
SQLUDF_SMALLINT *outNumberNullI nd,
SQLUDF_TRAIL_AR GS)
{
if (*number1NullIn d == -1 || *number2NullInd == -1)
{
*outNumberNullI nd = -1;
}
else
{
*outNumber = *number1 | *number2;
*outNumberNullI nd = 0;
}
}

#ifdef __cplusplus
extern "C"
#endif
void SQL_API_FN Bit_Xor(SQLUDF_ BIGINT *number1,
SQLUDF_BIGINT *number2,
SQLUDF_BIGINT *outNumber,
SQLUDF_SMALLINT *number1NullInd ,
SQLUDF_SMALLINT *number2NullInd ,
SQLUDF_SMALLINT *outNumberNullI nd,
SQLUDF_TRAIL_AR GS)
{
if (*number1NullIn d == -1 || *number2NullInd == -1)
{
*outNumberNullI nd = -1;
}
else
{
*outNumber = *number1 ^ *number2;
*outNumberNullI nd = 0;
}
}

#ifdef __cplusplus
extern "C"
#endif
void SQL_API_FN Bit_Not(SQLUDF_ BIGINT *number1,
SQLUDF_BIGINT *outNumber,
SQLUDF_SMALLINT *number1NullInd ,
SQLUDF_SMALLINT *outNumberNullI nd,
SQLUDF_TRAIL_AR GS)
{
if (*number1NullIn d == -1)
{
*outNumberNullI nd = -1;
}
else
{
*outNumber = ~*number1;
*outNumberNullI nd = 0;
}
}

#ifdef __cplusplus
extern "C"
#endif
void SQL_API_FN Bit_Shift_Left( SQLUDF_BIGINT *number1,
SQLUDF_INTEGER *shift,
SQLUDF_BIGINT *outNumber,
SQLUDF_SMALLINT *number1NullInd ,
SQLUDF_SMALLINT *shiftNullInd,
SQLUDF_SMALLINT *outNumberNullI nd,
SQLUDF_TRAIL_AR GS)
{
if (*number1NullIn d == -1 || *shiftNullInd == -1)
{
*outNumberNullI nd = -1;
}
else if (*shift < 0 || *shift > 63)
{
strcpy(SQLUDF_S TATE, "38999");
strcpy(SQLUDF_M SGTX, "Shift out of range");
}
else
{
*outNumber = *number1 << *shift;
*outNumberNullI nd = 0;
}
}

#ifdef __cplusplus
extern "C"
#endif
void SQL_API_FN Bit_Shift_Right (SQLUDF_BIGINT *number1,
SQLUDF_INTEGER *shift,
SQLUDF_BIGINT *outNumber,
SQLUDF_SMALLINT *number1NullInd ,
SQLUDF_SMALLINT *shiftNullInd,
SQLUDF_SMALLINT *outNumberNullI nd,
SQLUDF_TRAIL_AR GS)
{
if (*number1NullIn d == -1 || *shiftNullInd == -1)
{
*outNumberNullI nd = -1;
}
else if (*shift < 0 || *shift > 63)
{
strcpy(SQLUDF_S TATE, "38999");
strcpy(SQLUDF_M SGTX, "Shift out of range");
}
else
{
*outNumber = *number1 >> *shift;
*outNumberNullI nd = 0;
}
}

#ifdef __cplusplus
extern "C"
#endif
void SQL_API_FN Bit_Hex2Num(SQL UDF_VARCHAR *hex,
SQLUDF_BIGINT *outNumber,
SQLUDF_SMALLINT *hexNullInd,
SQLUDF_SMALLINT *outNumberNullI nd,
SQLUDF_TRAIL_AR GS)
{
if (*hexNullInd == -1)
{
*outNumberNullI nd = -1;
}
else
{
*outNumber = 0;
for (*outNumber = 0; *hex != '\0'; hex++)
{
*outNumber <<= 4;
switch (*hex)
{
case '0': break;
case '1': *outNumber |= 1; break;
case '2': *outNumber |= 2; break;
case '3': *outNumber |= 3; break;
case '4': *outNumber |= 4; break;
case '5': *outNumber |= 5; break;
case '6': *outNumber |= 6; break;
case '7': *outNumber |= 7; break;
case '8': *outNumber |= 8; break;
case '9': *outNumber |= 9; break;
case 'A':
case 'a': *outNumber |= 10; break;
case 'B':
case 'b': *outNumber |= 11; break;
case 'C':
case 'c': *outNumber |= 12; break;
case 'D':
case 'd': *outNumber |= 13; break;
case 'E':
case 'e': *outNumber |= 14; break;
case 'F':
case 'f': *outNumber |= 15; break;
default:
{
strcpy(SQLUDF_S TATE, "38999");
strcpy(SQLUDF_M SGTX, "Unknown character");
}
}
}
*outNumberNullI nd = 0;
}
}

#ifdef __cplusplus
extern "C"
#endif
void SQL_API_FN Bit_Num2Hex(SQL UDF_BIGINT *number,
SQLUDF_VARCHAR *outHex,
SQLUDF_SMALLINT *numberNullInd,
SQLUDF_SMALLINT *outHexNullInd,
SQLUDF_TRAIL_AR GS)
{
int i;
if (*numberNullInd == - 1)
{
*outHexNullInd = -1;
}
else
{
for (i = 15; i >= 0; *number >>= 4, i--)
{
switch (*number & 0xf)
{
case 0: outHex[i] = '0'; break;
case 1: outHex[i] = '1'; break;
case 2: outHex[i] = '2'; break;
case 3: outHex[i] = '3'; break;
case 4: outHex[i] = '4'; break;
case 5: outHex[i] = '5'; break;
case 6: outHex[i] = '6'; break;
case 7: outHex[i] = '7'; break;
case 8: outHex[i] = '8'; break;
case 9: outHex[i] = '9'; break;
case 10: outHex[i] = 'A'; break;
case 11: outHex[i] = 'B'; break;
case 12: outHex[i] = 'C'; break;
case 13: outHex[i] = 'D'; break;
case 14: outHex[i] = 'E'; break;
case 15: outHex[i] = 'F'; break;
default: {}
}
}
outHex[16] = 0;
*outHexNullInd = 0;
}
}

#ifdef __cplusplus
extern "C"
#endif
void SQL_API_FN Bit_Test(SQLUDF _BIGINT *number,
SQLUDF_INTEGER *bitPos,
SQLUDF_SMALLINT *outBool,
SQLUDF_SMALLINT *numberNullInd,
SQLUDF_SMALLINT *bitPosNullInd,
SQLUDF_SMALLINT *outBoolNullInd ,
SQLUDF_TRAIL_AR GS)
{
if (*numberNullInd == -1 || *bitPosNullInd == -1)
{
*outBoolNullInd = -1;
}
else if (*bitPos < 0 || *bitPos > 63)
{
strcpy(SQLUDF_S TATE, "38999");
strcpy(SQLUDF_M SGTX, "Bit position out of range");
}
else
{
if (*number & (((SQLUDF_BIGIN T) 1) << *bitPos))
{
*outBool = 1;
}
else
{
*outBool = 0;
}
*outBoolNullInd = 0;
}
}

#ifdef __cplusplus
extern "C"
#endif
void SQL_API_FN Bit_Set(SQLUDF_ BIGINT *number,
SQLUDF_INTEGER *bitPos,
SQLUDF_BIGINT *outNumber,
SQLUDF_SMALLINT *numberNullInd,
SQLUDF_SMALLINT *bitPosNullInd,
SQLUDF_SMALLINT *outNumberNullI nd,
SQLUDF_TRAIL_AR GS)
{
if (*numberNullInd == -1 || *bitPosNullInd == -1)
{
*outNumberNullI nd = -1;
}
else if (*bitPos < 0 || *bitPos > 63)
{
strcpy(SQLUDF_S TATE, "38999");
strcpy(SQLUDF_M SGTX, "Bit position out of range");
}
else
{
*outNumber = *number | (((SQLUDF_BIGIN T) 1) << *bitPos);
*outNumberNullI nd = 0;
}
}

#ifdef __cplusplus
extern "C"
#endif
void SQL_API_FN Bit_Clear(SQLUD F_BIGINT *number,
SQLUDF_INTEGER *bitPos,
SQLUDF_BIGINT *outNumber,
SQLUDF_SMALLINT *numberNullInd,
SQLUDF_SMALLINT *bitPosNullInd,
SQLUDF_SMALLINT *outNumberNullI nd,
SQLUDF_TRAIL_AR GS)
{
if (*numberNullInd == -1 || *bitPosNullInd == -1)
{
*outNumberNullI nd = -1;
}
else if (*bitPos < 0 || *bitPos > 63)
{
strcpy(SQLUDF_S TATE, "38999");
strcpy(SQLUDF_M SGTX, "Bit position out of range");
}
else
{
*outNumber = *number & ~(((SQLUDF_BIGI NT) 1) << *bitPos);
outNumberNullIn d = 0;
}
}

udfbit.clp:
-- Bigint functions 64 Bit wide
CREATE FUNCTION BIT_AND(BIGINT, BIGINT) RETURNS BIGINT
SPECIFIC BIT_AND EXTERNAL NAME 'udfbit!Bit_And '
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_OR(BIGINT, BIGINT) RETURNS BIGINT
SPECIFIC BIT_OR EXTERNAL NAME 'udfbit!Bit_Or'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_XOR(BIGINT, BIGINT) RETURNS BIGINT
SPECIFIC BIT_XOR EXTERNAL NAME 'udfbit!Bit_Xor '
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_NOT(BIGINT) RETURNS BIGINT
SPECIFIC BIT_NOT EXTERNAL NAME 'udfbit!Bit_Not '
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_SHIFT_RIGHT (BIGINT, INTEGER) RETURNS BIGINT
SPECIFIC BIT_SHIFT_RIGHT EXTERNAL NAME 'udfbit!Bit_Shi ft_Right'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_SHIFT_LEFT( BIGINT, INTEGER) RETURNS BIGINT
SPECIFIC BIT_SHIFT_LEFT EXTERNAL NAME 'udfbit!Bit_Shi ft_Left'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_HEX2NUM(VAR CHAR(16)) RETURNS BIGINT
SPECIFIC BIT_HEX2NUM EXTERNAL NAME 'udfbit!Bit_Hex 2Num'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_NUM2HEX(BIG INT) RETURNS VARCHAR(16)
SPECIFIC BIT_NUM2HEX EXTERNAL NAME 'udfbit!Bit_Num 2Hex'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_TEST(BIGINT , INTEGER) RETURNS SMALLINT
SPECIFIC BIT_TEST EXTERNAL NAME 'udfbit!Bit_Tes t'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_CLEAR(BIGIN T, INTEGER) RETURNS BIGINT
SPECIFIC BIT_CLEAR EXTERNAL NAME 'udfbit!Bit_Cle ar'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_SET(BIGINT, INTEGER) RETURNS BIGINT
SPECIFIC BIT_SET EXTERNAL NAME 'udfbit!Bit_Set '
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

-- Varchar fucntions (1024 Bit wide
CREATE FUNCTION BIT_AND(VARCHAR (128) FOR BIT DATA,
VARCHAR(128) FOR BIT DATA)
RETURNS VARCHAR(128) FOR BIT DATA
SPECIFIC BIT_AND EXTERNAL NAME 'udfbit!Bit_And Vc'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_OR(VARCHAR( 128) FOR BIT DATA,
VARCHAR(128) FOR BIT DATA)
RETURNS VARCHAR(128) FOR BIT DATA
SPECIFIC BIT_OR EXTERNAL NAME 'udfbit!Bit_OrV c'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_XOR(VARCHAR (128) FOR BIT DATA,
VARCHAR(128) FOR BIT DATA)
RETURNS VARCHAR(128) FOR BIT DATA
SPECIFIC BIT_XOR EXTERNAL NAME 'udfbit!Bit_Xor Vc'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION (VARCHAR(128) FOR BIT DATA,
VARCHAR(128) FOR BIT DATA)
RETURNS VARCHAR(128) FOR BIT DATA
SPECIFIC BIT_NOT EXTERNAL NAME 'udfbit!Bit_Not Vc'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION (VARCHAR(128) FOR BIT DATA,
VARCHAR(128) FOR BIT DATA)
RETURNS VARCHAR(128) FOR BIT DATA
SPECIFIC BIT_SHIFT_RIGHT EXTERNAL NAME 'udfbit!Bit_Shi ft_RightVc'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION (VARCHAR(128) FOR BIT DATA,
VARCHAR(128) FOR BIT DATA)
RETURNS VARCHAR(128) FOR BIT DATA
SPECIFIC BIT_SHIFT_LEFT EXTERNAL NAME 'udfbit!Bit_Shi ft_LeftVc'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_TEST(VARCHA R(128) FOR BIT DATA, INTEGER)
RETURNS SMALLINT
SPECIFIC BIT_TEST EXTERNAL NAME 'udfbit!Bit_Tes tVc'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_CLEAR(VARCH AR(128) FOR BIT DATA, INTEGER)
RETURNS VARCHAR(128) FOR BIT DATA
SPECIFIC BIT_CLEAR EXTERNAL NAME 'udfbit!Bit_Cle arVc'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;

CREATE FUNCTION BIT_SET(VARCHAR (128) FOR BIT DATA, INTEGER)
RETURNS VARCHAR(128) FOR BIT DATA
SPECIFIC BIT_SET EXTERNAL NAME 'udfbit!Bit_Set Vc'
NOT FENCED RETURNS NULL ON NULL INPUT
DETERMINISTIC NO SQL NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE SQL ALLOW PARALLEL;
udfbit.exp:
Bit_And
Bit_Or
Bit_Xor
Bit_Not
Bit_Shift_Right
Bit_Shift_Left
Bit_Hex2Num
Bit_Num2Hex
Bit_Test
Bit_Set
Bit_Clear

udfbit.def (Windows):
LIBRARY UDFBIT
DESCRIPTION 'Library for DB2 Bit UUDF'
EXPORTS
Bit_And
Bit_Or
Bit_Xor
Bit_Not
Bit_Shift_Right
Bit_Shift_Left
Bit_Hex2Num
Bit_Num2Hex
Bit_Test
Bit_Set
Bit_Clear
compile and deploy using the samples/c/bldrtn script.

Enjoy
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7403
by: Kevin Frey | last post by:
Hello, I have a test database with table A containing 10,000 rows and a table B containing 100,000 rows. Rows in B are "children" of rows in A - each row in A has 10 related rows in B (ie. B has a foreign key to A). Using ODBC I am executing the following loop 10,000 times, expressed below in pseudo-code: "select * from A order by a_pk option (fast 1)"
18
2364
by: pb648174 | last post by:
Greeting, below is the complete SQL taken from aspfaq.com (retrieved from this newsgroup I believe) The query takes about two minutes to run. Does anybody have a better set based way (sub-second response) to determine business days? CREATE TABLE dbo.Calendar ( dt SMALLDATETIME NOT NULL PRIMARY KEY
10
3973
by: AC Slater | last post by:
I have 1 table (out of many) that has very poor performance when performing a select into on. The select statement is called multiple times. We've found each call to take almost 1 second... we were expecting less than .1 seconds. The select stmt looks like: select key,data into key_buff, data_buff from tablename where key > curr_key AND key < max_key ORDER by key FETCH FIRST 1 ROW ONLY;
1
2433
by: Evan Smith | last post by:
My database is suffering from poor performance of late. Reports that used to run in a reasonable time, now take a while. The explain output show that the query is fully indexed, and the statistics are up to date. Using a statement monitor I was able to determine that a particular query took 545 seconds of real time to run, yet only 19 seconds of CPU. According to my system monitoring tools, I had plenty of idle CPU cycles and free memory...
3
5260
by: sac | last post by:
I am using DB2 v8.1 on UNIX. At times the database shows extremely poor performance. I do not have dba/admin rights nor do I have the web based client for db2 v8.1. I have only command line access. Also DBA support starts after our jobs have completed. (1) Is there any command that I could use from command line to find out the process taking up maximum of the database resources ? (2) Can the database snapshot be used for this purpose ?...
20
2105
by: John Mark Howell | last post by:
I had a customer call about some C# code they had put together that was handling some large arrays. The performance was rather poor. The C# code runs in about 22 seconds and the equivalent C++.Net code runs in 0.3 seconds. Can someone help me understand why the C# code performance is so poor? I rewote the C# code to use a single dimenional array and the time went down to about 3 seconds, but that's still no explaination as to why the...
2
2417
by: Brian Tabios | last post by:
Hello Everyone, I have a very complex performance issue with our production database. Here's the scenario. We have a production webserver server and a development web server. Both are running SQL Server 2000. I encounted various performance issues with the production server with a particular query. It would take approximately 22 seconds to return 100 rows, thats about 0.22 seconds per row. Note: I ran the query in single user mode. So...
2
1561
by: BTabios | last post by:
Hello Everyone, I have a very complex performance issue with our production database. Here's the scenario. We have a production webserver server and a development web server. Both are running SQL Server 2000. I encounted various performance issues with the production server with a particular query. It would take approximately 22 seconds to return 100 rows, thats about 0.22 seconds per row. Note: I ran the query in single user mode. So...
4
2680
by: Jim Devenish | last post by:
I have converted an Access back-end to SQL Server back-end but am having some problems. The Access to Access application has been running well for some years. I have successfully copied all the data to SQL Server and linked the tables to the front end .mdb (I am not using .adp). Some queries were performing poorly so I have converted these to Views and linked to them. Everything works well with good response but when about 8-10...
4
2391
by: joa2212 | last post by:
Hello everybody, I'm posting this message because I'm quiet frustrated. We just bought a software from a small software vendor. In the beginning he hosted our application on a small server at his office. I think it was a Fujitsu-Siemens x86 running debian Linux. The performance of the DSL-Line was very poor, so we decided to buy an own machine to host the application ourselves.
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.