Hi there! My little nephew is a bad boy that called me last day, and was really busy, so him assured to take a look before or later... the before or later worry me.
I just did a stupid test by the way, and i see into a table like you provided that contain just 5126 rows, a query like your return
Showing rows 0 - 24 (25 total, Query took 0.0005 sec)
but often it return
Showing rows 0 - 24 (25 total, Query took 0.0006 sec)
while a more basic query like this (to be easier i excluded the LIMIT clause on both sinceit is assumed that it will have same effect on both results):
SELECT item_number,field12 FROM testtable1 USE INDEX (combo1) WHERE field1 = '1201'
return
Showing rows 0 - 24 (25 total, Query took 0.0004 sec)
so maybe if you after manipulate the result like this:
$res0
is the resulting array given by the above query:
Code: Select all
$item_number = array_column($res0,'item_number');
$field12 = array_column($res0,'field12');
$ar = array_combine($field12, $item_number);
ksort($ar);
echo '<pre>';
print_r($ar);
so
$ar
will contain after another php iteration, extracted data needed for the part
WHERE item_number in (our results inserted here)
the thing could be little faster, since resulting array count is just 50 records?
Anyway about this, looking into your first question, i do not have completely understand why you check for:
Code: Select all
SELECT item_number
FROM TESTTABLE1
then again
Code: Select all
SELECT item_number
FROM TESTTABLE1
is it faster for you re-call a query like this, instead to select all needed row values, into the first query?
but maybe i have not well understand this part.
Partitioning the table could be another solution, since there are millions of records?
[EDITED]