|
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]
|