|
Vern, thanks for taking a kick at the can; I'm not surprised at your results. I tried CREATE INDEX on each of the columns and (with STRDBG) and the Optimizer indicated it used the index. It's time for a real test, I guess... I thought about EVI's but I thought I read (in the "Query Performance and Optimization" manual?) they're better on columns with a relatively small number of values. In thinking about an alternative solution, I've come up using with a trigger on the PF to write cross-reference entries to a finder file. But it's so "System/36"-like it makes me gag. It could be ITER... Thanks, reeve -----Original Message----- From: midrange-l-admin@midrange.com [mailto:midrange-l-admin@midrange.com]On Behalf Of Vernon Hamberg Sent: Saturday, September 21, 2002 2:17 AM To: midrange-l@midrange.com Subject: RE: Better SQL performance with UNION? Well, I tried some of my own suggestions. I had three columns I wanted to include, along with a customer key field. I had the longest field in the first SELECT of the UNION. No matter what I used, it chose arrival sequence. When I ran it with no indexes available, the optimizer suggested building indexes on the respective 2nd column. I tried this, both with normal indexes and with EVIs. The estimated time with no indexes was 20 seconds. With normal indexes, 21 seconds. With EVI, 29 seconds. I also tried indexes on the respective column 2 and the customer key, hopin it'd do an index-only access method. Nope. Same time estimates. It was interesting that, with EVIs, the first SELECT was executed in arrival sequence with bitmap processing, meaning it used the EVI. But the 2nd and 3rd SELECTs did not use bitmap processing. Curious. Results were the same, whether I used a compare value early in the alphabet or one that was quite high in the alphabet. Using DEGREE(*OPTIMIZE) was faster - 2 of the selects used bitmap processing with EVIs. Estimate was 15 seconds. Better yet was when the keys were normal indexes, of, e.g., C_NAME, C_CUSTKEY. The first select was processed using the logical, index-only. The second used the logical, not index-only, the third one was arrival sequence. Estimated time, 12 seconds, for a search starting with 'X', 14 seconds for one from 'D'. So the best results should come from using indexes that support each SELECT in the UNION. These should be normal (not EVI) indexes, each with 2 fields, the first being the WHERE clause field and the second being cmcust. Query attribute DEGREE should be *OPTIMIZE or *MAX. BTW, the OPTIMIZE FOR n ROWS clause had no effect. Test file has about 150,000 records, record length is 223, columns used were C_NAME (25 char), C_ADDRESS (40 char), and C_PHONE (15 char), plus the common field C_CUSTKEY (BIN 4) Bottom line - it was slow. Machine is a 270-2248 with 1517 interactive feature Regards Vern _______________________________________________ This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/midrange-l or email: MIDRANGE-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.