|
Hi Brian, in iSeries Navigator a logical file is always considered as view and not as index. For example, the page size of a keyed logical file is 8K while the page size of an index is 64K. A logical file can share access path with an index and adopt it's page size, if the index is created first. A logical file can share access path with indexes and logical files that have the same or more key fields in the same order. A SQL index will only share access path with an other index, where the key fields are an exact match. A logical file can be specified in an SQL statement (because it's used like a view), while an index is only implicitely used by the query optimizer. In RPG a SQL index can be used like a keyed logical file in the F-Specs. Besides a logical file is handled like a view in SQL the query optimizer searches both indexes and keyed logical files to find the optimal access path. Do you know if the index you created is really used or is it a guess? I'll try it again to explain you how to find the Visual Explain and the index advisor. (It's a little difficult, becaus I've only the German Version of the iSeries navigator and the translation is sometimes not very good.) The following steps show you, how to execute and analyze an SQL statement: 1. Start iSeries Navigator 2. Open your Connection 3. Open Database 4. Position on your Database 5. Select Run an SQL Script in the Database Tasks on the left bottom site. Once opened Run an SQL script execute the following steps: 1. Type your SQL statement 2. Mark your SQL statement 3. Open Visual Explain 4. Select either Explain or Run Explain You will see if the complete file is read (table scan) or if an index (or keyed logical file) is used. If you want to see if an index is requested, just click on Action and Advisor. Birgitta -----Ursprungliche Nachricht----- Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]Im Auftrag von Brian Piotrowski Gesendet: Mittwoch, 20. Juli 2005 19:03 An: RPG programming on the AS400 / iSeries Betreff: RE: DB2 SQL View Resources Thanks for the great info, Birgitta. Looking at my table through Navigator, I checked PROPERTIES -> INDEXES, and there is NOTHING listed in the box. However, when I check the source files, there are several fields that are keyed. I'm confused now...I always thought that when you keyed a file, it would automatically become it's index. Is that not the case? When I look at our directory structures in Navigator, I see there are a few indexes set up for physical files (listed as an INDEX), and logical files (listed as VIEWS). I just tried to set up an index on the pf using plcd/ptno/ptcl/ivchk as the fields in the index. When I reran the query, it didn't appear to do much for performance. Thanks, Brian. -----Original Message----- From: Hauser, Birgitta [mailto:Birgitta.Hauser@xxxxxxxxxxx] Sent: Wednesday, July 20, 2005 9:51 AM To: 'rpg400-l@xxxxxxxxxxxx' Subject: RE: DB2 SQL View Resources >>Can someone point me to some resources that explain on how to create >>views in DB2 and how to call them from RPG? CREATE VIEW MySchema/MyView As Select Field1, Field2, ... FieldN From MySchema/MyFile Where IVCHK in (3, 5) An SQL-View can be used in RPG like a logical file, but be aware, a view never has a key. If you need a predefined sequence, you have to use embedded SQL and add an ORDER BY clause in your SELECT statement. >>I'm still wrestling with this problem I had yesterday about retrieving >>info. Currently, the table is sitting at 2.9 Million records. However, >>within the records, there are only 218,000 that I need (I only need >>records with an IVCHK status of 3 or 5). I tried creating a LF only >>using these records, but it was still slow. >>Would creating a view based on a set of criteria speed up my process? Creating a view will only speed up your process, if you have created the right indexes. The easiest way would be, to use iSeries Navigator. Start iSeries Navigator, select database, select the library you need, execute a SQL script. Within SQL script you have a wizart for visual explain. Execute your SQL statement interactively and analyze it with visual explain. There is also a Index advisor, that will show you which index should be created. Birgitta -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-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.