[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Speeding up querys
I forgot the subject in my last message..
Hi guys,
I have a problem with my slow queries. I have a group-table that contains
skus to a users-table. I would need to pull out all existing info
(phone-numbers, addresses etc. if any) from the members-table on each match
from the group table.
I found the Embedded-Perl example in the icfaq
(http://icdevgroup.org/cgi-bin/ic/docfly.html?mv_arg=icfaq14%2e02), and
testing that method on the user-table speeded up the query dramatically. My
problem is now that how should I combine these tables via embedded Perl. I
think that I should first split the members skus, and after that loop each
and compare it with each sku from the users table. I jut don't know how to
continue.. :(
This is my piece of code I have for the moment from the icfaq:
[query arrayref=myref sql="select * from users"]
<!-- make query, this container text is not used. -->
[/query]
[perl]
# Get the query results, has multiple fields
my $ary = $Tmp->{myref};
my $out = '';
foreach $line (@$ary)
{
my ($sku, $name, $address) = @$line;
if($sku eq $Scratch->{waiting_for})
{
$out .= "sku: $sku name: $name address: $address<br>\n";
}
}
return $out;
[/perl]
And these are my tables..
Members table:
---------------------------
| sku | member |
---------------------------
| vip | 1,4,6,14,25,46 |
---------------------------
Users table
------------------------
|sku | name | phone |
------------------------
| 1 | name1 | phone1 |
------------------------
| 2 | name2 | phone2 |
------------------------
| 3 | name3 | phone3 |
------------------------
I would be thankful if someone could give me some hints or advice.
Regards, René