You are here: Re: Efficient Uniqueness Check « PHP Programming Language « IT news, forums, messages
Re: Efficient Uniqueness Check

Posted by Alan Little on 10/12/06 11:17

Carved in mystic runes upon the very living rock, the last words of
<petersprc@gmail.com> of comp.lang.php make plain:

> Alan Little wrote:
>> I have affiliates submitting batches of anywhere from 10 to several
>> hundred orders. Each order in the batch must include an order ID,
>> originated by the affiliate, which must be unique across all orders
>> in all batches ever submitted by that affiliate. I'm trying to figure
>> out the most efficient way to check the uniqueness of the order ID.
>>
>> The two ways I'm considering are: 1) a single query to load all the
>> affiliate's order IDs into an array for checking as I process the
>> batch; 2) creating a temporary table with just the affiliate's IDs,
>> querying it for each order in the batch.
>>
>> Any ideas which would be more efficient? Would there be any
>> significant difference either way?
>
> Perhaps this could work: If you keep the submissions in a set of
> staging tables, then your unique key would work.

Thanks, but that isn't really practical; all orders are maintained in the
orders table, so inserting them into an intermediate table would just be
another step. Using a single table, I would have to flag the records as
temporary, as I added them, then remove the flag upon successful
completion, or delete the flagged records upon failure. With an
intermediate table, I wouldn't have the deletion problem, but I would
still then have to copy them to the permanent table upon success, which
(one would hope) would be the majority of cases.

> Of the things you're considering, a single query would be more
> scalable, but it's like you won't notice much difference at all until
> the volume went up.

That's kind of what I figured, that even with an order of magnitude of
tens of thousands of past records, it wouldn't make much difference
either way. I just wondered about the efficiency of having to loop over
all those records from the single query, and load them into an array, but
I think that would be the most efficient.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация