php sql fetch query optimization
I am working with PHP and Oracle. While executing queries I am using oci_set_prefetch()
method before oci_execute()
for fast fetching. As my output is large I am setting it to 1000. Though time for whole execution is now less but still not satisfactory. Same query if run on database directly brings data in 2-3 seconds whereas while executing through PHP 开发者_运维问答methods it takes much more time.
Is there any other method for reducing this fetch time ?
Thanks in advance
Your setting of the oci_set_prefetch parameter is increasing the latency of your query; that is, the delay between the time you issue the query and the time you get your first results. You've instructed Oracle to wait until it has 1000 rows of data before starting to send them to PHP. It is diligently following your instructions.
You see a fast result in sql*plus or whatever interactive query client you're using because you see the first row of your resultset fairly quickly, and you're fooled into thinking the whole query is fast because the results are spewing past you.
Do you need the whole thousand rows? Try turning off the prefetch parameter and see if you get more favorable results. Try limiting the length of your resultset with AND ROWNUM <= 10
or some such thing, and see if it helps.
精彩评论