Re: using Win32::ODBC - what's fast?
From: Fred (noemail_at_#$&&!.net)
Date: 10/29/04
- Next message: James Willmore: "Re: Parsing 'dirty/corrupt data'. Advice wanted"
- Previous message: D. Marxsen: "Re: Parsing 'dirty/corrupt data'. Advice wanted"
- In reply to: Matt Garrish: "Re: using Win32::ODBC - what's fast?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 29 Oct 2004 07:02:43 -0400
On Thu, 28 Oct 2004 22:30:14 -0400, Matt Garrish wrote:
> Are all your tables indexed on the select column to maximize for speed?
They are indexed on that column, but good point.
> Why are you reading all 70,000 unique ids into memory?
I thought it would be faster than doing it each time. Even with the index,
it just *seemed* exspensive, but I see what you mean about the connection.
( and the where clause!!)
>It would be faster
> just to execute a select statement each time you need to check if an sku
> already exists. I've never used the Win32::ODBC module, but if you were
> using the DBD driver you could just check whether the unit id exists
> like so: (untested)
>
> sub check_exists {
>
> my ($tid, $unitid) = @_;
>
> my $sel_sth = $dbh->prepare("SELECT sku from $tid WHERE sku = ?") or
> die
> $dbh->errstr();
>
> $sel_sth->execute($unitid) or die $dbh->errstr();
>
> if ($sel_sth->fetchrow_array) {
> $sel_sth->finish();
> return 1;
> }
>
> return 0;
>
> }
>
> Remember that most of the overhead involved in database access is in
> setting up the connection. Once you have that connection, querying the
> database should be very fast (assuming your data is well structured and
> indexed).
>
> Matt
I see now that including the where cluase leverages the power of the
index.. and individual selects start looking a lot better. Can't wait to
to test and thanks very much for your insight! Plus I'll try out the
driver you mention and test the diff. In the beginning when I was learning
perl, (circa 6 months ago) Win32::ODBC was the first thing I found tor
acessing MS DB's... so I learned it and never looked back. Bad practice in
'theory' but in real life when people want things done yesterday.... Thank
you again!
Fred
- Next message: James Willmore: "Re: Parsing 'dirty/corrupt data'. Advice wanted"
- Previous message: D. Marxsen: "Re: Parsing 'dirty/corrupt data'. Advice wanted"
- In reply to: Matt Garrish: "Re: using Win32::ODBC - what's fast?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|