in reply to Re: performance with mysql / file-caching / hash reference on demand
in thread performance with mysql / file-caching / hash reference on demand
Thank you very much for your reply.
The webshop is built on the base of a Links management system which would work with mod_perl.
Some of my code for customer related operations might cause hiccup with mod_perl, so I fear using mod_perl a little.
For displaying detailed pages I work with speedycgi since a couple of years which did improve performance significant.
As far as I have seen one problem is what your question implies.
I loose performance because there are connections built to mysql more often than probably neccessary.
This seems to be more my problem with Perl than a general problem though PHP which I try to avoid seems to be quicker there out of the box.
My webserver is a couple of years old but still is performant and works with SSD:
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 24 On-line CPU(s) list: 0-23 Vendor ID: GenuineIntel CPU family: 6 Model: 45 Model name: Intel(R) Xeon(R) CPU E5-2640 0 @ 2.50GHz Stepping: 7 CPU MHz: 2499.711 BogoMIPS: 5000.02 Virtualization: VT-x
total used free shared buffers cached Mem: 96455 65478 30976 0 4752 53994 -/+ buffers/cache: 6730 89724 Swap: 949 0 949
At the moment a detailed page needs about 1.1 seconds to display but I want to add significant more information and I would like to get faster - at least not slower.
One code example I am using to get media (images, datasheets) from the DB:
sub get_udx_media_relations { my $SupplierID = shift; my $SupplierPID = shift; my $return; my $query = qq|SELECT ProviderID, SourceID, Folder, Filename, Extension, Purpose, Rank, Priority, Width, Height FROM CT_Media_Relations WHERE SupplierID = '$SupplierID' AND SupplierPID = '$SupplierPID' AND isDeleted != 'Yes' GROUP BY Filename, Extension ORDER BY Priority DESC, Rank ASC|; my $sth = $DB->table('CT_Media_Relations')->prepare ($query) || die $GX::SQL::error; $sth->execute (); my ($prev_priority); while ($_ = $sth->fetchrow_hashref) { if ($prev_priority->{$_->{Purpose}} > $_->{Priority}) { next unless $_->{Purpose} eq 'PDB'; } #get rid of mds when manufacturer is present (4 vs 5) if ($_->{Purpose} eq 'AAB' or $_->{Purpose} eq 'EBD' or $_->{Purpose} eq 'PBS' or $_->{Purpose} eq 'PRI') { if ($prev_priority->{IMG} > $_->{Priority}) { next; } else { $prev_priority->{IMG} = $_->{Priority}; } } $prev_priority->{$_->{Purpose}} = $_->{Priority}; if ($_->{Purpose} eq 'PRI' && !$return->{Primary}->{path}) { $return->{Primary} = $_; $return->{Primary}->{path} = '/dx/' . $_->{ProviderID} . "/" . $_->{SourceID}; $return->{Primary}->{filename} = $_->{Filename} . '.' . $_->{Extension}; $return->{Primary}->{filename} = $_->{Folder} . '/' . $return->{Primary}->{filename} if $_->{Folder}; } my $media = $_; $media->{path} = '/dx/' . $_->{ProviderID} . "/" . $_->{SourceID}; $media->{filename} = $_->{Filename} . '.' . $_->{Extension}; $media->{filename} = $_->{Folder} . '/' . $media->{filename} if $_->{Folder}; push(@{$return->{$_->{Purpose}}}, $media); } push(@{$return->{IMG}}, @{$return->{EBD}}) if defined(@{$return->{EBD}}); if ( not defined(@{$return->{IMG}}) and defined (@{$return->{PBS}}) ) { push(@{$return->{IMG}}, @{$return->{PBS}}); } push(@{$return->{IMG}}, @{$return->{AAB}}) if defined(@{$return->{AAB}}); if (defined @{$return->{IMG}} && (!$return->{Primary} || $return->{Primary}->{Priority} < $return->{IMG}[0]->{Priority})) { $return->{Primary} = shift @{$return->{IMG}}; } push(@{$return->{IMG}}, @{$return->{PAB}}) if defined(@{$return->{PAB}}); push(@{$return->{IMG}}, @{$return->{DET}}) if defined(@{$return->{DET}}); return $return; }
My thought was that it could make sense to put these results in a static whatever state (database, file) on a daily basis to avoid doing the same routine over and over agein.
Cheers derion
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: performance with mysql / file-caching / hash reference on demand
by afoken (Chancellor) on May 02, 2021 at 11:05 UTC | |
by derion (Sexton) on May 02, 2021 at 12:20 UTC | |
by hippo (Archbishop) on May 02, 2021 at 13:53 UTC | |
by derion (Sexton) on May 02, 2021 at 14:56 UTC |