Gossamer Forum
Home : Products : Gossamer Links : Discussions :

What do you think of it?

Quote Reply
What do you think of it?
What do you think of it?
The script

/cgi-bin/links/admin/Links/User/Search.pm
(package Links::User::Search)

is a bit wrong. Apparently, it is an ideological problem of all scripts in library Links. The developer didn't think about the speed of the script an the use of its resources.

>> Line 98,Char1 =======================
my $links = $Links::DB->table('Links');
my $categories = $Links::DB->table('Category');

# We don't do a category search if we only have a filters.
my $filter = 0;
if (! defined $query or ($query eq '')) {
$filter = 1;
}
$args->{filter} = $filter;

# Then do the search.
$args->{callback} = \&_cat_search_subcat if ($args->{catid});
my $orig_sb = $args->{sb};
my $orig_so = $args->{so};
$args->{sb} = $CFG->{build_sort_order_search_cat};
$args->{so} = '';
$filter and $args->{sb} =~ s/score//;
my $cat_sth = $categories->query_sth ($args) unless ($filter);
my $cat_count = $filter ? 0 : $categories->hits();

$args->{callback} = \&_search_subcat if ($args->{catid});
$args->{sb} = $orig_sb ? $orig_sb : $CFG->{build_sort_order_search} || '';
$args->{so} = (defined $orig_so and $orig_so =~ /^(asc|desc)$/i) ? $1 : 'ASC';
$filter and $args->{sb} =~ s/score//;
my $link_sth = $links->query_sth ($args);
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: LABEL1
Selection of all the records is actually made here.
The keywords won't help in this case as LIKE is used here. The inquiry looks as LABEL3
There ar��nly" 350000 records in the table.
# =================================
my $link_count = $links->hits;

# Return if no results.
unless ($link_count or $cat_count) {
return { error => Links::language('SEARCH_NOLINKS'), term => $term };
}

# Now format the category results.
my $count = 0;
my ($category_results, @category_results_loop);
if (!$filter and $cat_count) {
while (my $cat = $cat_sth->fetchrow_hashref) {
last if ($count++ > $args->{mh});
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: LABEL2
But we need only $args->{mh} records, it can be done with the help of LIMIT in the inquiry itself, it will unload the server in many times. We are not Google, therefore it is possible to do without calculation of the total amount of records and show nonlinear paging.
# ====================================================
my $title = Links::Build::build ('title_linked', { name => $cat->{Full_Name}, complete => 1, home => 0 });
$category_results .= "<li>$title\n";
$cat->{title_linked} = $title;
push @category_results_loop, $cat;
}
}

# And format the link results.
my ($link_results, %link_output);
if ($link_count) {
my $results = $link_sth->fetchall_hashref;
$links->add_reviews ($results);
if ($CFG->{build_search_gb}) {
my @ids = map { $_->{ID} } @$results;
my $catlink = $DB->table('CatLinks','Category');
my %names = $catlink->select ('LinkID', 'Full_Name', { LinkID => \@ids })->fetchall_list;
foreach my $link (@$results) {
push @{$link_output{$names{$link->{ID}}}}, $link;
}
}
else {
push @{$link_output{none}}, @$results;
}
}
<<<<< ======================================

LABEL3:
SELECT * FROM lsql_Links WHERE ( ( ( ( Title LIKE '%test%' OR Description LIKE '%test%' OR URL
LIKE '%test%' ) ) ) AND ( isValidated = 'Yes' ) )
==============================
Quote Reply
Re: [Evg@] What do you think of it? In reply to
I don't see your point?

Quote:
is a bit wrong. Apparently, it is an ideological problem of all scripts in library Links. The developer didn't think about the speed of the script an the use of its resources.

I'm sure they did think about it. Remember, they have different indexing types (to speed up searches on large databases), so this may be why they have done this.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!