I've got a UDF that is used on the publishing side of a data warehouse:
when the data is headed out to a mart. It works fine for sets of a few
thousand rows, but really slows for sets of a few million rows: a
query will go from one to thirty minutes due to two calls on each row.
Any suggestions or advise?
-----------------------------------------------------------------------------
-- convert ip from integer format to string format
-- ex: from 3232235621 to 192.168.0.101
-----------------------------------------------------------------------------
create function IP2STRING(IP_BI GINT bigint)
returns varchar(15)
deterministic
no external action
begin atomic
declare node_1 bigint;
declare node_2 bigint;
declare node_3 bigint;
declare node_4 bigint;
SET node_1 = MOD(BIGINT(ip_b igint / 16777216), 256);
SET node_2 = MOD(INTEGER(ip_ bigint / 65536), 256);
SET node_3 = MOD(INTEGER(ip_ bigint / 256), 256);
SET node_4 = MOD(ip_bigint, 256);
return RTRIM(CHAR(node _1)) || '.' || RTRIM(CHAR(node _2)) || '.' ||
RTRIM(CHAR(node _3)) || '.' || RTRIM(CHAR(node _4));
end
Am I missing any good opportunities to speed this up?
Any faster algorithm or functions to switch to?
Or should I consider a java routine with bitfiddling (yuck)?
Or give up on this approach and move the logic out of the database
(dang)?
Thanks in advance!
Ken 3 2128
kenfar wrote: I've got a UDF that is used on the publishing side of a data warehouse: when the data is headed out to a mart. It works fine for sets of a few thousand rows, but really slows for sets of a few million rows: a query will go from one to thirty minutes due to two calls on each row. Any suggestions or advise?
----------------------------------------------------------------------------- -- convert ip from integer format to string format -- ex: from 3232235621 to 192.168.0.101 ----------------------------------------------------------------------------- create function IP2STRING(IP_BI GINT bigint) returns varchar(15) deterministic no external action begin atomic declare node_1 bigint; declare node_2 bigint; declare node_3 bigint; declare node_4 bigint; SET node_1 = MOD(BIGINT(ip_b igint / 16777216), 256); SET node_2 = MOD(INTEGER(ip_ bigint / 65536), 256); SET node_3 = MOD(INTEGER(ip_ bigint / 256), 256); SET node_4 = MOD(ip_bigint, 256); return RTRIM(CHAR(node _1)) || '.' || RTRIM(CHAR(node _2)) || '.' || RTRIM(CHAR(node _3)) || '.' || RTRIM(CHAR(node _4)); end
Am I missing any good opportunities to speed this up? Any faster algorithm or functions to switch to? Or should I consider a java routine with bitfiddling (yuck)? Or give up on this approach and move the logic out of the database (dang)?
Today SQL UDF which include BEGIN ATOMIC are serialized.
In a DPF enviroment (which I presuem you're in) this means that got
yourself a bottlenck. It will also limit the optimization capabilities
of the optimizer
SQL UDF work great when you can reduce them to only RETURN:
create function IP2STRING(IP_BI GINT bigint)
returns varchar(15)
deterministic
no external action
contains sql
return RTRIM(CHAR(MOD( BIGINT(ip_bigin t / 16777216), 256)))
|| '.' || RTRIM(CHAR(MOD( INTEGER(ip_bigi nt / 65536), 256)))
|| '.' || RTRIM(CHAR(MOD( INTEGER(ip_bigi nt / 256), 256)))
|| '.' || RTRIM(CHAR(MOD( ip_bigint, 256)))
Enjoy
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Serge, SQL UDF work great when you can reduce them to only RETURN:
Thanks! That worked perfect.
Today SQL UDF which include BEGIN ATOMIC are serialized. In a DPF enviroment (which I presuem you're in) this means that got yourself a bottlenck. It will also limit the optimization capabilities of the optimizer
Any suggestions for reference material on this subject? Is Paul Yip's
book the best resource?
Ken Farmer
kenfar wrote: Serge,
SQL UDF work great when you can reduce them to only RETURN:
Thanks! That worked perfect. Today SQL UDF which include BEGIN ATOMIC are serialized. In a DPF enviroment (which I presuem you're in) this means that got yourself a bottlenck. It will also limit the optimization capabilities of the optimizer
Any suggestions for reference material on this subject? Is Paul Yip's book the best resource?
Not sure how much he has on this topic. Assuming your email address
works I just sent you and (aged) DBM Tech presentation.
If you want to get really into things you can read up the patents: http://patft.uspto.gov/netahtml/search-bool.html
5,987,455 Intelligent compilation of procedural functions for query
processing systems
5,963,934 Intelligent compilation of scripting language for query
processing systems
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Randell D. |
last post by:
Folks,
I have a Javascript performance question that I might have problems
explaining...
In PHP, better performance can be obtained dealing directly with a
variable, as opposed to an element in an array... Thus, if I have a
programming routine that utilises $a several times, it is better to
write the value contained in $a to something else, for example,
$vartmp, and have my routine instead use this for its work... I believe
|
by: Mark Shelor |
last post by:
I've encountered a troublesome inconsistency in the C-language Perl
extension I've written for CPAN (Digest::SHA). The problem involves the
use of a static array within a performance-critical transform function.
When compiling under gcc on my big-endian PowerPC (Mac OS X),
declaring this array as "static" DECREASES the transform throughput by
around 5%. However, declaring it as "static" on gcc/Linux/Intel
INCREASES the throughput by...
|
by: Martin |
last post by:
I am using graphics as backgrounds for forms,buttons,labels etc.
The question is: is it faster to load all graphics from files on app start
or
to use it embeded (places in editor during design).
Reason for my question is that application has 5mb, while without graphics
it has cca 400kb.
Graphic files (bmps) take about 200kb (in program, they are repeated many
times, ie almost all labels (around 200) have same background image)).
Also,...
|
by: bjarne |
last post by:
Willy Denoyette wrote;
> ... it
> was not the intention of StrousTrup to the achieve the level of efficiency
> of C when he invented C++, ...
Ahmmm. It was my aim to match the performance of C and I achieved that
aim very early on. See, for example "The Design and Evolution of C++".
-- Bjarne Stroustrup; http://www.research.att.com/~bs
|
by: Mike |
last post by:
Lets just say my app is done HOO HOO.
Now, I'm accessing the database via a web service and one thing i noticed
that my app is running real slow. When I first started working on the app is
ran pretty quick returned the data to the screens in about 2 - 3 seconds. Now
its going about 5 - 10 seconds. How can I beef it up for better performance.
| |
by: Rune B |
last post by:
Hi Group
I was considering using a Generic Dictionary<> as a value container inside
my business objects, for the reason of keeping track of fields changed or
added and so on.
- But how expensive is it to instantiate/use Generic Dictionaries in great
numbers (let's just say 100000's ), in terms of memoryuse and performance?
Any practical experiences out there?
|
by: Varangian |
last post by:
Hi,
I have a performance issue question?
which is best (in terms of efficiency and performance, I don't care
neatness in code)... building an ArrayList of Object Instances using
SqlDataReader OR using SqlDataAdapter to Fill a DataSet or DataTable ?
Thanks!
|
by: Markus Ernst |
last post by:
Hello
A class that composes the output of shop-related data gets some info
from the main shop class. Now I wonder whether it is faster to store the
info in the output class or get it from the main class whenever it is
needed:
class shop_main {
var $prices = null;
function &get_prices() {
|
by: toton |
last post by:
Hi,
I want a few of my class to overload from a base class, where the
base class contains common functionality. This is to avoid repetition
of code, and may be reducing amount of code in binary, not to get
polymorphic behavior.
None of them has virtual methods, and are self contained (no
destructor at all) thus do not have a chance to have memory error.
Thus the derived classes has additional functionality, not additional
data.
|
by: galiorenye |
last post by:
Hi,
Given this code:
A** ppA = new A*;
A *pA = NULL;
for(int i = 0; i < 10; ++i)
{
pA = ppA;
//do something with pA
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |