Gossamer Forum
Home : Products : Gossamer Links : Discussions :

performance difference do_query prepare + execute

Quote Reply
performance difference do_query prepare + execute
Hi there - probably hi Andy, Robert and Vishal,

I am working with the optimization of queries and wonder if there is an effect if I use
Code:
sub {
my $brand_id = shift;
my $query = qq|SELECT
Contact_Email
FROM glinks_Links
WHERE
BrandID = ? LIMIT 0,1|;
my $sth = $DB->table('Links')->prepare ($query) || undef;
$sth->execute ($brand_id);
return $sth->fetchrow_hashref;
}
over
Code:
sub {
my $brand_id = shift;
my $query = qq|SELECT
Contact_Email
FROM glinks_Links
WHERE
BrandID = ? LIMIT 0,1|;
return $DB->table('Links')->do_query($query) || undef;
}

While the second is shorter as far as I know it is better and probably faster with mySQL to use placeholders. I yet not figurered out if LinksSQL does call mySQL with placeholders or if both of the above lead to the same request and placeholder micht be more secure.

Thanks for your input

n||i||k||o
Subject Author Views Date
Thread performance difference do_query prepare + execute el noe 3279 May 6, 2021, 12:09 AM
Thread Re: [el noe] performance difference do_query prepare + execute
el noe 3220 May 6, 2021, 3:36 AM
Thread Re: [el noe] performance difference do_query prepare + execute
Andy 3221 May 6, 2021, 8:03 AM
Thread Re: [Andy] performance difference do_query prepare + execute
el noe 3208 May 6, 2021, 8:35 AM
Thread Re: [el noe] performance difference do_query prepare + execute
Andy 3204 May 6, 2021, 8:56 AM
Post Re: [Andy] performance difference do_query prepare + execute
el noe 3162 May 11, 2021, 1:17 AM