Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Query Speed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Query Speed

    I have noticed that the Query Genie does not take full advantage of available indexes in the production CDX.

    For example if my file has a first name index and a lastname index and I do a query on first and last name using the genie it scans the entire file until a record that matches is found or it runs out of records (which could be a long time in some cases).

    Is there a way to help the geni or is this an "add on" waiting to happen?

    I come (am comming) from a FoxPro environment and the system does seem to be much faster in this regard using the SQL SELECT syntax but a program can still be faster.

    djl

    djl

    #2
    RE: Query Speed

    the query genie just generates a filter expression.

    the issue is whether the filter expression that the genie generates is optimizable.

    in order to answer that question, you need to show us what filter the genie generated for you.

    i just did a test on a 100,000 record table. i used the genie to generate a filter for lastname = "smith", "jones" or "king". the filter it generated was:

    (Lastname = "jones" .or. Lastname = "smith" .or. Lastname = "king" )

    and then, since i had a lastname index, a5 did the query in just a few seconds, and returned 200 or so records.

    Comment


      #3
      RE: Query Speed

      I had to "and" the value for the first name and last name.

      I was looking for a specific name in the table.

      I guess for a filter to work you would have to scan all the records.

      It takes about 15 seconds in FoxPro for that query and less than 1 second using a prg that "seeks" the lastname value then loops looking for the first name. The table is ordered on last name. If one does this kind of thing often then writing a little prg in Alpha with a Xdialog input would probally get somewhere near the same results as the FoxPro program.

      BTW the query in Alpha V.5 takes 104 seconds with the geni.

      I tried the "order by" tab but that seems to be applied to the output. I thought that it may set the indexes for the origional scan.

      Comment


        #4
        RE: Query Speed

        I'm sorry, I forgot to mention that I am testing with a copy of our production table of about 700,000 names. The record is way long and not very optimized. This is a legacy system that is being replace a little at a time.

        djl

        Comment


          #5
          RE: Query Speed

          a5 does NOT have to scan all records to do a query. i am not sure how you would arrive at that conclusion.

          Lightening Query Optimization in A5 should be very similar to Foxpro's query optimization.

          You could have a table of millions of records, and a "seek" (foxpro's term) , or a "find" (a5's term) which positions the record pointer at a specific record in an index will be essentially instantaneous in a5v5. once you have positioned the record pointer, looping through records that match a particular index key will be very quick.

          i still need to see the query that the genie generated for you.

          Comment


            #6
            RE: Query Speed

            ---------------------
            a5 does NOT have to scan all records to do a query. i am not sure how you would arrive at that conclusion.
            ---------------------

            I see the counter in the status area in the bottom od=f the window go through all of the records giving the count and the % done. When it reaches 100% the result set shows. It scans all of the records.

            ---------------------
            Lightening Query Optimization in A5 should be very similar to Foxpro's query optimization.

            You could have a table of millions of records, and a "seek" (foxpro's term) , or a "find" (a5's term) which positions the record pointer at a specific record in an index will be essentially instantaneous in a5v5.
            ---------------------
            I find that this is indeed corect. It is essentially instantaneous if the table is ordered on the index for a field that you are finding a value on.


            ---------------------
            once you have positioned the record pointer, looping through records that match a particular index key will be very quick.
            ---------------------

            That is what I thought but I havn't written a little procedure to test it. In fact, I'll have to look at the documentation to see how to start.




            ---------------------
            i still need to see the query that the genie generated for you
            ---------------------

            Filter Expression
            (RLFIRSTNAM = "David" ) .AND. (RLLASTNAM = "LEYANNA" )

            Order Expression
            RLFIRSTNAM+RLLASTNAM

            There are the following indexes available in the production .CDX

            name of index "mtaglastna" expression UPPER(rllastnam)
            name of index "mtagfirstn" expression rlfirstnam




            I hope I have provided the information you have requested.
            Thanks for your help.
            djl

            Comment


              #7
              RE: Query Speed

              i just recreated a table with 20,000 records using the same fieldnames and indexes that you have and did a query. a5 used LQO, and did not have to scan all records.

              to figure out why LQO is not kicking in for your table, i would have to see the files. was the .cdx created by foxpro? it is possible that a5 is not recognizing it.

              if you go to the index builder in a5 and rebuild these indexes, and then redo the query, does a5 then use LQO.

              with regard to how to do a find, and then process records in xbasic, here is how you could do it.
              assume that the table is called "customer"
              the index tag is called "lastname".
              you want to scan for "smith"

              t = table.open("customer")
              i = t.index_primary_put("lastname")
              t.fetch_find("smith")
              while t.lastname = "smith"
              'do whatever you want to each record here
              t.fetch_next()
              end while

              Comment


                #8
                RE: Query Speed

                Selwyn and Dave,

                Pardon me for jumping in...

                I think the issue Dave is seeing is because he does not yet have an index built on lastname AND firstname. He has one on lastname, and one on firstname. His query however is for a specific lastname AND a specific firstname.

                The solution may be simple, why not build an index on Lastname & Firstname, so that the query can use it?

                If I'm off base, please, will somebody tell me to butt out.

                -- tom

                Comment


                  #9
                  RE: Query Speed

                  Thanks Tom;

                  I'm aware of this kind of solution but this is an old system written in FoxPro with over 65 programs that refer to index names by number and the .CDX already has 35 indexes in it. Very Ugly.

                  Some optimizing engines could use the last name index to find all the last names that are correct and then use the firstname index to see which records in that index are in the first result set. Because the record sizes are smaller for indexes and the can process the index sequencially (pardon the spelling) it dos not have to transvers the entire second index, onlt the part of the index that has the correct value for first name. For example if there were 300 "David"s in the first name index and the first "David" was the 500th record, it would skip to the 500th record to get to the first "David" look at the record number that that one is pointing to, see if that record number is in the first result set of correct last names and process the next 300 records in like manner. If the Names database has 600,000 records it only had to look at 300 of them to see if any match for first name instead of all 600,000 if an index was not used.

                  All behind the curtain, mind you...

                  djl

                  Comment


                    #10
                    RE: Query Speed

                    I'm working on reindexing the production CDX in Alpha5v5. It's taking a long time but thats because of having 35 flippin indexes in it. (Not my design, but I can't change it right now...)

                    I thank you for the code snippit.
                    You are being most helpfull


                    djl

                    Comment


                      #11
                      RE: Query Speed

                      Dave,

                      Beware of using a different definition for the index key tags than you will be using in the query. As you know, there's a big difference between a character field and a trimmed character field. -- tom

                      Comment


                        #12
                        RE: Query Speed

                        tom

                        a5's LQO does not require an index on "lastname + firstname".

                        if you have one index on lastname
                        and another index on firstname, then a query

                        lastname = "smith" .and. firstname = "john" is optimizable.

                        Comment


                          #13
                          RE: Query Speed

                          Well...

                          The entire cdx is reindexed while in Alpha and there is no difference in the speed. 104 seconds.

                          I guess the next step is to actually CREATE the CDX in Alpha and try it that way.

                          I'll keep you posted.

                          djl

                          BTW,
                          I saw the post to Tom about two seperate indexes and I am encouraged.

                          Comment


                            #14
                            RE: Query Speed

                            Did not know that. Thanks.

                            -- tom

                            Comment


                              #15
                              RE: Query Speed

                              I've read this with interest. I'll be interested to know the outcome.

                              I noticed that the last name index was using UPPER:
                              name of index "mtaglastna" expression UPPER(rllastnam)

                              Could this be causing an issue with LQO?

                              Comment

                              Working...
                              X