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

Why Does A SQL Inner Join Bring Performance To A Crawl?

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

  • Why Does A SQL Inner Join Bring Performance To A Crawl?

    I have a List based on a SQL query and it works just fine when it is based on a single table query.
    I would like a field in another table which can be linked through a common ID field. Two tables: Repairs (13,000 records) and Machines (25 records).

    But when the Inner Join is added to the query (see highlighted section in screenshot), it brings the entire performance of the List to a crawl, including List Quick Searches and Detail Searches.

    Why would I be taking such a massive hit just by adding an inner join to the query in an Alpha list?
    Running the same query in SSMS is lightning fast, returning results in less than a second.

    Inner Join.jpg
    Last edited by iRadiate; 08-25-2021, 02:11 PM.
    Alpha Anywhere v12.4.6.4.2 Build 8245-5650 IIS v10.0 on Windows Server 2019 Std in Hyper-V

  • #2
    Is repairs.MacID indexed, I recently introduced more indexes to my joined query tables and this helped

    Comment


    • #3
      Ditto on the index, but if it is fast in SSMS, then I am guessing the index is there.

      Thought 1)
      My next thought would be - do you really need all of those fields in the query?

      If not, I would remove any fields you do not need. The amount of data being pulled in will have an effect on the list being populated.

      Thought 2)
      You should try creating this select statement as a view. So create a view with the exact same statement and then try pulling the view into the list instead of doing the join inside the list query as you are now.

      You may find that to be much faster also.

      Comment


      • #4
        Originally posted by Lance Gurd View Post
        Is repairs.MacID indexed, I recently introduced more indexes to my joined query tables and this helped
        Lance, yes the tables are indexed.
        Alpha Anywhere v12.4.6.4.2 Build 8245-5650 IIS v10.0 on Windows Server 2019 Std in Hyper-V

        Comment


        • #5
          Originally posted by lgrupido View Post
          Ditto on the index, but if it is fast in SSMS, then I am guessing the index is there.

          Thought 1)
          My next thought would be - do you really need all of those fields in the query?

          If not, I would remove any fields you do not need. The amount of data being pulled in will have an effect on the list being populated.

          Thought 2)
          You should try creating this select statement as a view. So create a view with the exact same statement and then try pulling the view into the list instead of doing the join inside the list query as you are now.

          You may find that to be much faster also.
          Larry,

          Thought 1 - I do need the fields.

          Thought 2 - I've never done that, create a view. So not sure how you do that or how you use it, but I will do some reading and look into it.

          Thanks for the suggestions.
          Alpha Anywhere v12.4.6.4.2 Build 8245-5650 IIS v10.0 on Windows Server 2019 Std in Hyper-V

          Comment


          • #6
            From within SSMS, use the following:

            create view myviewname as
            select statement

            That will create the view and then you use it in Alpha like you would any table.

            Caveat: Your select statement looks like it should create an editable view, but if not you may need to do some manual updating if you intend to use this list to update records. (other than saving it in a standard detail view.)

            Comment


            • #7
              I've been avoiding lists because A. my first try created a horribly slow experience, and B. They seem far too complicated to work with compared to a grid.
              With that said, for purposes of testing the sql statement, I would try it with a grid or even a simple (non-list/viewbox) ux.
              Gregg
              https://paiza.io is a great site to test and share sql code

              Comment


              • #8
                Originally posted by iRadiate View Post

                Lance, yes the tables are indexed.
                I don't just mean that the tables are indexed, I mean the the linking field in both tables is indexed in a separate index, in your case this would be an index on MACID in the repairs table and MACHINEID in the machines table

                Comment


                • #9
                  Lance just use a view.
                  Insanity: doing the same thing over and over again and expecting different results.
                  Albert Einstein, (attributed)
                  US (German-born) physicist (1879 - 1955)

                  Comment


                  • #10
                    Originally posted by Lance Gurd View Post

                    I don't just mean that the tables are indexed, I mean the the linking field in both tables is indexed in a separate index, in your case this would be an index on MACID in the repairs table and MACHINEID in the machines table
                    I see what you mean, the 2 tables have clustered indexes on the primary keys. So repairs is indexed on repairid (not macid). And machines is indexed on machineid. These were the auto generated indexes by SQL when the tables were created.
                    So, I 'could' add a non-clustered index on repairs.macid.

                    What I really don't understand is why the query runs fast in SSMS but in Alpha it is painfully slow. (only when the query is changed to use the join).
                    However, I will try your suggestion to see if it helps, though I want to try this on my test system first not the production system.

                    Thanks
                    Last edited by iRadiate; 08-26-2021, 08:40 AM.
                    Alpha Anywhere v12.4.6.4.2 Build 8245-5650 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                    Comment


                    • #11
                      It definitely helped me, views a others have suggested is a great way to go so that SQL does all the work of getting the data you want. Then there is sub-queries to get your data, in my experience these are blindingly fast in comparison to a normal join

                      Comment


                      • #12
                        Yes, definitely some good options to explore.

                        Thanks to all for the great suggestions.
                        Alpha Anywhere v12.4.6.4.2 Build 8245-5650 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                        Comment


                        • #13
                          Rendering 13,000 records into your list is what might be slowing you down. The query is fast in SSMS. Not sure how a view would help. The list still needs to render 13K records.

                          Have you tried playing with the virtualization options? You can limit the number of rows rendered in the list.

                          Ashampoo_Snap_Thursday, August 26, 2021_08h17m28s_001_.png
                          Mike Brown - Contact Me
                          Programmatic Technologies, LLC
                          Programmatic-Technologies.com
                          Independent Developer & Consultant

                          Comment


                          • #14
                            Just to demonstrate how drastic a performance hit Alpha is introducing to the list query, take a look at this:

                            1. Alpha List - Query Without Join (< 2 seconds)

                            https://www.screencast.com/t/cGj5l5NEe


                            2. Alpha List - Query With Join (> 15 seconds)

                            https://www.screencast.com/t/pSISxYjzy9f


                            3. SSMS - Query With Join (< 1 second)

                            https://www.screencast.com/t/mh5S46yGX
                            Last edited by iRadiate; 08-26-2021, 09:32 AM.
                            Alpha Anywhere v12.4.6.4.2 Build 8245-5650 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                            Comment


                            • #15
                              Originally posted by mikeallenbrown View Post
                              Rendering 13,000 records into your list is what might be slowing you down. The query is fast in SSMS. Not sure how a view would help. The list still needs to render 13K records.

                              Have you tried playing with the virtualization options? You can limit the number of rows rendered in the list.

                              Ashampoo_Snap_Thursday, August 26, 2021_08h17m28s_001_.png
                              I'm only bringing back 100 rows at a time in the List with pagination.

                              List Pagination.jpg


                              Virtualization.jpg

                              The problem is with what Alpha is doing with the query behind the scenes. Have a look at the comparison videos above.
                              Last edited by iRadiate; 08-26-2021, 09:57 AM.
                              Alpha Anywhere v12.4.6.4.2 Build 8245-5650 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                              Comment

                              Working...
                              X