Re: Re: [PHP-DB] Re: [PHP] Re: the opposite of a join?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John A DAVIS wrote:
left join where item in right table is null

That's still going to look at all records in both tables:

1) so it can work out if there is a match from table 1 to table 2
2) so it can then remember to display any records that don't have a match

I was thinking more that if you have something like this:

select * from table1 where id not in (select id from table2);

The db might take that and turn it into:

select * from table1 where id not in (id1,id2,id3);

But it doesn't really matter.

Either way you end up with full table or index scans (depending on the db and engine you are using if mysql) of both table1 and table2.

myisam tables might just be able to use an index to do this sort of work, innodb will have to do a table scan because it's mvcc (as will postgres and others).

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux