James, read up "SQL Union Tip" article on page 6 of this newsletter:
http://www.centerfieldtechnology.com/publications/archive/SeptOct08.pdf
If you can use UNION ALL without functional implications, it might help
reduce "query running" time.
If the only query is by part number, you can build an index over part number
on all 3 fields (3 separate indexes). You can make them binary radix index
(default) or an EVI (Encoded Vector Index).
DB2 for i can perform bitmap merging for both type of indexes.
Command to use to build indexes is CREATE INDEX. You can use interactive
SQL (STRSQL command) to build them, or iNav's Run SQL Scripts (click on
Start->Run->cwbundbs->OK [provided you have IBM Client Access installed on
your PC]).
Hth, Elvis
Celebrating 11-Years of SQL Performance Excellence on IBM i, i5/OS and
OS/400
www.centerfieldtechnology.com
-----Original Message-----
Subject: Re: Searching across three files
Thanks, "sjl", Roger, and Vern; that did the trick.
Using one of the files of the QuestView demonstration suite (namely
VIEWPRT) as a guinea-pig, I split it into three files (VIEWPRT1,
VIEWPRT2, and VIEWPRT3), removed a few records, and added a few, so that
I ended up with three files with a slight overlap between them. I then did:
CREATE VIEW VIEWPRTC AS SELECT * FROM MERCURY.VIEWPRT1 UNION SELECT
* FROM MERCURY.VIEWPRT2 UNION SELECT * FROM MERCURY.VIEWPRT3
which created the desired dynamically consolidated logical. Opening it
from QuestView caused a slight delay with "query running" messages, but
quickly coughed up the consolidated part-catalog files. The acid test,
tying it into the look-up specs and calling the lookup program in
"command-line test" mode also produced the desired results.
One thing: how would I index this, for better performance if the user is
doing the look-up by part-number? Unfortunately, while I vaguely
remember SQL indexing from a class I took in Rochester, neither my
memory nor my copy of "SQL for Dummies" have a whole lot to say on the
subject.
As an Amazon Associate we earn from qualifying purchases.