1 2 3 Previous Next 30 Replies Latest reply on May 16, 2016 12:20 PM by shawkins Go to original post
      • 15. Re: help needed troubleshooting slow odbc usage
        shawkins

        > From what I can see the issue is that we are misreporting atttypmod for many column types.  This appears to hit a unexpected path in the driver which then causes the re-fetching of the column metadata.

         

        Now that I have this fully reproduced, I can see that this is not what is going on so I'll keep digging.  It does look like we do need an issue on atttypmod  and may need an issue on the performance of the column metadata query as well.

        • 16. Re: help needed troubleshooting slow odbc usage
          m.ardito

          Hi Steven, sorry to be late but in these days I'm more out of office then usual...

           

          Current teiid server is 8.13.3, but I could try others if needed.

           

          The table as said above is in mysql server, defined in the simplest way as a model in a dynamic vdb

           

          in the zip attached you'll find mysql create, teiid ddsl and vdb xml, hth.

           

          In the next days  planned to

          - replicate the table 'ag' on real postgres server, and debug/trace odbc selecting from php/odbc on that table.

           

          - replicate the above selection on windows, and debug/trace odbc selecting from php/odbc on that table.

           

          I feel - just feel - that I aready tried something similar in windows, with much faster results.

          I never felt teiid odbc slow linking tables from windows/msaccess, in the past. But this was for older teiid versions... And I could be wrong, as usual

          Odata queries seemed much faster then php/odbc on that same linux server, iirc.

          I could also try libreoffice on linux, linking teiid both with odbc and jdbc, if this helps.

           

          Feel free to suggest other setups, tests, other, I'll do whatever I'm able to help you guys...

          I just need some time and peace of mind in order to not add my own mistakes

           

          Marco

          • 17. Re: help needed troubleshooting slow odbc usage
            shawkins

            Actually it did turn out to be atttypmod, it's just that my initial fix wasn't sufficient.  I've logged [TEIID-4123] Issues with odbc metadata - JBoss Issue Tracker and [TEIID-4122] Improve performance of odbc client column metadata query - JBoss Issue Tracker to address this.

            • 18. Re: help needed troubleshooting slow odbc usage
              m.ardito

              I'm happy to hear that you had some success understanding my logs, because I dad not (I could not have) the faintest idea... 

               

              Do you think there is/was also a problem with the client opening multiple sessions, and would the above fixes also address that, if it was a problem?

               

              Marco

              • 19. Re: help needed troubleshooting slow odbc usage
                shawkins

                > Do you think there is/was also a problem with the client opening multiple sessions, and would the above fixes also address that, if it was a problem?

                 

                That is not clear.  If you have setup unixODBC to use a connection pool, then I would expect the connections to be reused.  Otherwise I can't really say what is going on there.  It seems like we would need to know more about the interaction between the php odbc logic and unixODBC to diagnose that.

                • 20. Re: help needed troubleshooting slow odbc usage
                  m.ardito

                  I just checked with the "real" postgrtesql server: it does happen the same thing, every page refresh gets a new session.

                  So this should not be on Teiid side... Now I need to dig into that too... any advice on where is best to post something about this? php ? postgresql ? unixodbc ?

                   

                  I tried to run the same script on a windows+php server, and the same script does not behave like that. Refreshing thre web page, te same connection is used...

                  Although there are so many differencies between my tested linux cases... all software versions are different... this will be though to solve, I fear...

                   

                  Anyway, is the first above (solved) issue in 9 beta 1? So that I could try it?

                   

                  Thanks,

                  Marco

                  • 21. Re: help needed troubleshooting slow odbc usage
                    shawkins

                    > any advice on where is best to post something about this? php ? postgresql ? unixodbc ?

                     

                    Likely you'll want to look at unixodbc - http://www.unixodbc.org/doc/conn_pool.html

                     

                    > Anyway, is the first above (solved) issue in 9 beta 1? So that I could try it?

                     

                    Yes the fix is in there and will be in 8.13.4 as well.

                    • 22. Re: help needed troubleshooting slow odbc usage
                      m.ardito

                      Just briefly tried 9 beta 1 and while it's definitely better (thanks) it's still much slower than direct mysql...

                      Of course there's the vdb overhead but... it's still too slow, although "usable" at least to start tests between the web server and teiid.

                       

                      the 50-field table is now loaded in about 0.6 - 0.7 seconds, from the lan, while direct mysql (odbc) often shows 0.002 - 0.02 seconds (edit: with SQL_NO_CACHE) for the same query and all.

                       

                      [edit] for comparison, teiid 8.13.3 times are between 4 and 12 seconds...[/edit]

                       

                      using odbc_pconnect sessions are still multiple, but this may be due to the php using different apache threads/process for every page reload.

                       

                      with odbc_connect teiid times grow to 0.8-0.9s while for mysql I get 0.015-0.020s for the same query. In this case of course no session is kept alive by teiid and mysql.

                       

                      I wonder what could be the benefit of solving TEIID-4122 in this respect... But at least,it's promising.

                       

                      In the next days I'll test more about 9 beta1 about my whole setup.

                       

                      Thanks,

                      Marco

                      • 23. Re: help needed troubleshooting slow odbc usage
                        shawkins

                        > the 50-field table is now loaded in about 0.6 - 0.7 seconds, from the lan, while direct mysql (odbc) often shows 0.002 - 0.02 seconds (edit: with SQL_NO_CACHE) for the same query and all.

                         

                        If it's the same as what you initially attached, then the core query/response time for Teiid is around 41 ms.  You should just use Teiid JDBC to tune that query performance in general. 

                         

                        All of the other ODBC connection, metadata, and cursoring related queries take up the rest of the time.  A fresh log would be good to confirm the time breakdown.

                         

                        > I wonder what could be the benefit of solving TEIID-4122 in this respect... But at least,it's promising.

                         

                        It should now just add constant overhead, which based upon your other logs was around  120 - 200 ms - so it alone may not get us there.  For small query results not using cursoring (declare fetch) will definitely help performance as there is less statement traffic - but it's less efficient for large results.  Also once we get even more of this cleared up, to get true timings you'll want to run a fair number of warm-up iterations.

                        • 24. Re: help needed troubleshooting slow odbc usage
                          m.ardito

                          Before try tuning teiid inner things, which I know nothing (yet) about, I'll try to have a good test case, not just a bunch of simple sql queries...

                          Also, in squirrelsql results of real-use queries with joins, even between non-jdbc models (like on "file" or "google" resource adapters) are quite fast, usually.

                           

                          If you know of some good test (eg that you can compare to other or previous results) let me know, I'll try my best to help you (providing logs or whatever needed).

                           

                          Just to add some better rough examples, today I tried to fetch a bigger result and modified my basic php test like you see below

                          This now gets all 50 columns for about 30k records. The results timing is between 2.0 and 2.5 seconds.

                          I also tried to include that query twice in the script, the second one with reversed order by, and the timing is roughly the same.

                           

                          <?php

                          $time_start = microtime(true);

                           

                          $dsn="teiid";

                          //$dsn="test";

                          //$dsn="mysql";

                          //$dsn="pgtest";

                          $connection = odbc_pconnect($dsn, $user, $password);

                          switch ($dsn) {

                            case "teiid":

                              $query_string="SELECT * FROM ag ";

                              break;

                            case "mysql":

                              $query_string="SELECT SQL_NO_CACHE * FROM ag WHERE id=7496";

                              break;

                          }

                           

                          echo "<li>Served by: $dsn";

                           

                          $result=odbc_exec($connection , $query_string);

                           

                          echo "<li>record count: " . odbc_num_rows($result); // <= this returns -1

                           

                          $time_end = microtime(true);

                          $time = $time_end - $time_start;

                           

                          echo "<li>Got results in $time seconds\n";

                           

                          $rc=0;

                          while($arr = odbc_fetch_array($result)) {

                              echo "<li>rn:".$rc++ . " => ". "id: " . $arr['id'] . " rs: " . $arr['rag_soc']. " pi: " . $arr['pi'];

                          }

                           

                          odbc_free_result($result) ;

                          ?>

                           

                          Marco

                          • 25. Re: help needed troubleshooting slow odbc usage
                            shawkins

                            > Before try tuning teiid inner things, which I know nothing (yet) about, I'll try to have a good test case, not just a bunch of simple sql queries...

                             

                            No, you don't need to tune inner things.  I just mean that the you'll want to look at the query performance over JDBC as the base Teiid performance case and tune the user queries / query plans from there if needed.  From there the overhead of ODBC should be much clearer.

                             

                            > If you know of some good test (eg that you can compare to other or previous results) let me know, I'll try my best to help you (providing logs or whatever needed).

                             

                            For the most part what you are seeing looks like constant overhead at this point.  Before the fix it was dependent upon the columns/types, but that should no longer be the case.  The only major odbc variation like I mentioned before would be to look at odbc performance with and without UseDeclareFetch.

                             

                            Ideally what you want to capture is a scenario with which you are satisfied with the Teiid JDBC performance, but for which the ODBC overhead seems disproportionate.  And it would be best if the client were the same machine either way.  Then with a fresh set of odbc debug logs we can see what contributed most to the overhead beyond what was already captured with TEIID-4122

                             

                            > I also tried to include that query twice in the script, the second one with reversed order by, and the timing is roughly the same.


                            It will take more than two iterations to see stable timings.  Note that there will be significant overhead in the first query (building some of the internal mat views) and beyond that you're allowing the vm warm up (the effects of JIT, vm sizing if it's not fixed, other Teiid caches, etc.) which does have a performance impact.

                            • 26. Re: help needed troubleshooting slow odbc usage
                              m.ardito

                              As said I need to define a more useful test script, but I tried quickly with/without usedeclarefetch...

                              running the same above sql queries, it seems that on that table (50 fields, 30k rows)

                              - with usedeclarefetch = 1 "select * from table" is slightly faster and "select * from table limit 25" is slightly slower

                              - with usedeclarefetch = 0 "select * from table" is slightly slower and "select * from table limit 25" is slightly faster

                               

                               

                              take this with a grain of salt, since it's really a raw quick test, I'll study something more useful

                               

                              I also thought to create two odbc dsn, one with and the other wthout usedeclarefetch,

                              and in the same script try both query types (with or without limits) on both odbc dsn (with or without usedeclarefetch)

                              I could also dump separately connection and response times for each case, and run queries either on same connection or closing/reopening it each time...

                              I could also iterate as many times as is useful connections and queries...

                               

                              As to compare JDBC/ODBC client performances I can think of a few alternatives

                              - Comparing "SquirrelSQL (jdbc->teiid, jdbc->mysql)" and "ODBC Query Tool (odbc->teiid, odbc->mysql)" timings

                              - Use an ETL like pentaho kettle to get data from teiid with OBC or JDBC and compare timings

                              .. or else (?)

                               

                              On the other hand, as said before, I have also a php script which uses odata (through curl request) to get the same data from teiid (paginated as in "select * from table limit 25") and it seems much, much speedier.

                              [edit]forget this, odata script was selecting just 3 fields... doing that, also odbc is much faster... sorry [/edit]

                               

                              Of course, in theory I could also use a mix of connection methods to get different kinds of data with different methods like Odata, odbc (w/wo/usedeclarefetch) or else...

                              But this would make app developement a bit more complex, probably. We'll see. But odbc timings optimization is my preferred solution, first.

                               

                              I also thought to use sqlrelay (SQL Relay), although I never used it, as a further intermediate abstraction layer between my php client (or else) and teiid.

                              It should be able to get client native mysql queries and relay them to different backend database, but it seems that it cannot connect through jdbc, unless I am missing somewthing, so it would not help. I'll ask there, if there is any way. It seems a useful bit of software, though. I don't know of any other similar tool, and I keep it under my radar, just in case.

                               

                              When the test suite is setup (again, please suggest whatever is best to help), I can get the teiid logs you need to maybe spot optimization paths...

                               

                              Thanks, also for your patience... this is going to be a long thread...

                              Marco

                              • 27. Re: help needed troubleshooting slow odbc usage
                                shawkins

                                TEIID-4122 will be addressed for Teiid 9.0 Beta2.  This should avoid a lot of the initial penalty of column metadata query.

                                • 28. Re: help needed troubleshooting slow odbc usage
                                  m.ardito

                                  Ok,

                                  I created a basic real-world application, and I am testing it. On 9beta.1

                                   

                                  Sometimes (it seemes random to me) it happens this error, and the application shows a page containing two separate logs:

                                  So:

                                  • php error:
                                    • "Severity: Warning
                                      Message: odbc_exec(): SQL error: [unixODBC]Could not send Query(connection dead); Could not send Query(connection dead), SQL state 08S01 in SQLExecDirect"
                                  • codeigniter (framework) error
                                    • "Error Number: 08S01

                                      [unixODBC]Could not send Query(connection dead); Could not send Query(connection dead)

                                      SELECT count(*) as n_az FROM ag"

                                   

                                  (the simple select is just the first query tried by the page model, to count page items)

                                   

                                  Usually simply reloading the page works (sometimes it needs two times).

                                   

                                  Note: I know I could work around this, using maybe an ajax request, to detect failures and retry the request, thus not crashing the app, but for now I just need to test if there are other connection problems (it could be a million reasons, I know).

                                   

                                  What can I do on Teiid side to get useful info, on those random errors?

                                  Marco

                                  • 29. Re: help needed troubleshooting slow odbc usage
                                    shawkins

                                    > What can I do on Teiid side to get useful info, on those random errors?


                                    The first thing to check is just the server log to see if there's a reason why we're closing the connection.  If there's nothing obvious it will take TRACE logging on the org.teiid.ODBC context so that we can see the client/server traffic.  If there's nothing there, then there may be an unixODBC issue.