Jump to content
Sign in to follow this  
pihug12

'Select' queries via pdo_sqlite are slow

Recommended Posts

Hello!

 

I found out that some 'SELECT' SQL queries are very slow with pdo_sqlite (PHP 5.3 or PHP 5.4).
The same query entered in the sqlite3 binary is way faster.

 

Here is my project : http://we.tl/59fGSVnAXh (password : "sqlite-php")

- bench.php

- chaines_centre.db

- inc_func.php

- info_job.php

 

The info_job.php page performs 5 'SELECT' queries in 10 seconds with my Apache server. A same query is perform in less than 0.2 seconds in the sqlite3 binary (so theoretically 1 second for the whole page).

 

I tried to modify the query a bit, and the results are strange :

 

Benchmark (bench.php) on the « $bdd->query(...); » instruction :

Query 2 : select DateMonteeAuPlan, Debut, Fin, Statut from ReportJobs where NomJob = 'NSAVBASE' and NomChaine like 'DCLC257%' limit 20;

=> 0.00099992752075195 seconde(s)

 

Query 3 : select DateMonteeAuPlan, Debut, Fin, Statut from ReportJobs where NomJob = 'NSAVBASE' and NomChaine = 'DCLC25736' order by DateMonteeAuPlan DESC limit 20;

=> 0 seconde(s)

 

Query 1 : select DateMonteeAuPlan, Debut, Fin, Statut from ReportJobs where NomJob = 'NSAVBASE' and NomChaine like 'DCLC257%' order by DateMonteeAuPlan DESC limit 20;

=> 1.8629999160767 seconde(s)

 

Why is there so much differences between two query quasi-identical?

How can I improve this situation to get results as fast as the sqlite3 binary?

 

Thanks if you took the time to look out my project files.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.