sql - Top level MySQL statistics -
have not been able find information on this, in own feel keeping in query might best option, if possible.
basically want try add top level "statistics" portion of query.
so when results see so
num_rows = 900 distinct_col = 9 results = array()
this way can loop results normally, , pull out information need once outside of it. possible?
edit: not looking normal mysql statistics num_rows exactly. in case lets limit results ten, num_rows return 10, want total results, 900. in cases use query , amount, combining 1 query logically seems faster me. there more num_rows may need, products , have specific category, need count amount of categories items fall under. looping raw results when there 1 result columns sillyness.
edit 2: clarify further need counts on columns, , maybe min-max result on join. having return on every loop work, same exact return uselessly returning on every loop when needed once not seem logical. no mysql expert , trying make sure come logical , fastest method required data.
here php return example:
array( [num_rows] => 900, [categories] => 9, [min_price] => 400, [max_price] => 900, [results] => array( [0] => //row array [1] -> //row array ) );
mysql returns default num rows before "fetch" results, having custom results added there may sufficient.
dunno why need that's easy get
assuming using safemysql (though can use whatever way data array)
$results = $db->getall("select * t"); $num_rows = count($results); $num_cols = count($results[0]);
that's all
i trying make sure come logical , fastest method required data.
yes, are.
nothing wrong getting aggregated data every loop.
as count beyond limits - when need it, can use mysql's sql_calc_found_rows / found_rows() feature
Comments
Post a Comment