PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table `test` (`id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`)) ENGINE=InnoDB
Copy Clear
Copy Format Clear
<?php $test_cases = [ range(0,50000), range(0,100000), range(0,150000), // range(0,500000), ]; foreach ($test_cases as $i => $ids) { echo "Iteration: $i\n"; $memory = 0; for ($j = 0; $j < 100; $j++) { $in = str_repeat('?,', count($ids) - 1) . '?'; $stmt = $pdo->prepare("SELECT `id` FROM `test` WHERE id IN ($in)"); $stmt->execute($ids); $stmt = null; gc_collect_cycles(); $newMemory = memory_get_usage(true); if ($memory !== $newMemory) { $memory = $newMemory; echo "$j: $memory\n"; } } }
Show:  
Copy Clear