note 33466 modified in function.array-intersect by vrana

From: Date: Tue, 17 Aug 2004 13:58:27 +0000
Subject: note 33466 modified in function.array-intersect by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79981@lists.php.net to get a copy of this message
If you have a slow database query that uses JOIN, try to array_intersect() the table records. I hung up my server countless times before using this function. Simple select from one table and put the records in an array ($records_1), then select records from any other table and put them in another array($records_2). array_intersect() will emulate a JOIN for you. <?php $emulated_join = array_intersect($records_1, $records_2); ?> Remember to test if it really offers a speed improvement, your mileage may vary (database type, hardware, version, etc...) You could also emulate a JOIN from two text files, reading each line with the file() function. --was-- If you have a slow database query that uses JOIN, try to array_intersect() the table records. I hung up my server countless times before using this function. Simple select from one table and put the records in an array ($records_1), then select records from any other table and put them in another array($records_2). array_intersect() will emulate a JOIN for you. $emulated_join = array_intersect($records_1, $records_2); Remember to test if it really offers a speed improvement, your mileage may vary (database type, hardware, version, etc...) You could also emulate a JOIN from two text files, reading each line with the file() function. http://php.net/manual/en/function.array-intersect.php

« previous php.notes (#79981) next »