VirtueMart Forum

VirtueMart 2 + 3 + 4 => Security (https) / Performance / SEO, SEF, URLs => Topic started by: sandomatyas on November 10, 2018, 20:44:07 PM

Title: Huge SQL queries
Post by: sandomatyas on November 10, 2018, 20:44:07 PM
Some crawler bot found a site of mine and within few hours it generates >2GB of slow queries log.
There was a lot of queries like this: https://prnt.sc/lgrf1y
Is it possible to optimize these somehow?
Title: Re: Huge SQL queries
Post by: GJC Web Design on November 10, 2018, 21:41:43 PM
same queries here .. he thinks its from the inventory view

http://forum.virtuemart.net/index.php?topic=141361
Title: Re: Huge SQL queries
Post by: sandomatyas on November 19, 2018, 13:01:07 PM
I digged a bit and found this in VirtueMartModelProduct
//This option switches between showing products without the selected language or only products with language.
if( $app->isSite() ){ //and !VmConfig::get('prodOnlyWLang',false)){
if((empty($this->keyword) or $group !== FALSE) and self::$omitLoaded and self::$_alreadyLoadedIds){
$where[] = ' p.`virtuemart_product_id`!='.implode(' AND p.`virtuemart_product_id`!=',self::$_alreadyLoadedIds).' ';
//$where[] = ' p.`virtuemart_product_id` NOT IN ('.implode(',',self::$_alreadyLoadedIds).') ';
}

} else {
//$joinLang = true;
}


When I removed this code part, the server worked fine.
As far as I can see, it's mod_virtuemart_products. I disabled 'omitLoaded' in every module, I don't need it actually, but maybe it worth to check. I'm not sure WHY the 'NOT IN' version was replaced to this
Title: Re: Huge SQL queries
Post by: Studio 42 on November 19, 2018, 13:06:29 PM
NOT IN is limited to a certain number of data, it's perhaps why they removed it.
But internally, if i'm right, Mysql change NOT IN to the appropriate query AND `virtuemart_product_id`!= ... so it's strange that one do a slow query and not the other one
Title: Re: Huge SQL queries
Post by: Milbo on November 19, 2018, 13:50:11 PM
changed in the new core vm3.4.3 to use not in and has doubled speed in case a lot products got already loaded.