Note that there are some explanatory texts on larger screens.

plurals
  1. POTroubleshooting MySQL to MSSQL PHP Query Translation and Speed
    primarykey
    data
    text
    <p>Firstly, if this is not the place for this type of question then please let me know and I will delete it.</p> <p>OK, so I have a MySQL PHP query translation class that translates to MSSQL among other databases. The following test file produces the following results (Debugging enabled)</p> <p><strong>Test_File.php</strong></p> <pre><code>include 'session_handler.php'; include 'database_connection.php'; $result = $db-&gt;query("SELECT * FROM industries LIMIT 5"); </code></pre> <p><strong>MySQL Results:</strong></p> <pre><code>Query time was 0.00622892379761 seconds for: SELECT * FROM industries LIMIT 5 Query time was 0.000350952148438 seconds for: SELECT "session_id" FROM "sessions" WHERE "session_id" = '58' Query time was 0.000293016433716 seconds for: UPDATE "sessions" SET "value" = 'x', "expiration" = '0' WHERE "session_id" = '58' Total query time: 0.00848698616028 seconds </code></pre> <p><strong>MSSQL Results</strong></p> <pre><code> Query time was 0.21740579605103 seconds for: SELECT c.table_schema AS "schema", c.table_name AS "table", c.column_name AS "column", c.data_type AS "type" FROM INFORMATION_SCHEMA.COLUMNS AS c WHERE (c.data_type = 'nvarchar' OR c.data_type = 'ntext' OR c.data_type = 'nchar') AND c.table_catalog = DB_NAME() ORDER BY lower(c.table_name) ASC, lower(c.column_name) ASC Query time was 0.21066212654114 seconds for: SELECT TOP 5 *, CAST("industries"."industry" AS VARBINARY(MAX)) AS fmssqln__industry FROM industries Query time was 0.21116590499878 seconds for: SELECT "session_id" FROM "sessions" WHERE "session_id" = '58' Query time was 0.21582698822021 seconds for: UPDATE "sessions" SET "value" = x, "expiration" = '0' WHERE "session_id" = '58' Total query time: 1.7053256034851 seconds </code></pre> <p>As you can see the MySQL query is extremely quick, whilst the converted query (converted by the class) take almost 2 seconds.</p> <p>I don't know anything about the syntax of MSSQL so I am not sure if the converted query is as optimised as it could be?</p> <p>So my questions are - is the converted MSSQL query a correct translation from the MySQL query, and where should I start to troubleshoot the speed issue?</p> <p><strong>Additional Information:</strong> The MSSQL and MySQL database and tables are identical, content and schema wise.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload