Post by websiteworld » Mon Mar 14, 2022 2:15 am

Our site is lightning fast, except for a successful customer login which takes 10 seconds! We are using some database caching tools from isenselabs so the site as a whole is lighting fast and scores 94 & 96 on GT Metrix. Can't figure out why a successful customer login is so slow. If the login is failed it gives a really quick failed login message.

This is a pretty active site with over 50,000 customers in the database. There are quite a few inactive customers, I wonder if I delete the inactive customers from the oc_customer table if that will help? Will that have any negative impact?

On a side note, we upgraded a OC 2.0 site to OC 3.0. For some reason it was a little slow, but I exported the database in MySQL Workshop and then re-imported it, and ever since the website has ran really quickly! So weird that helped somehow!
Last edited by websiteworld on Sat Mar 19, 2022 10:39 pm, edited 1 time in total.

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by thekrotek » Mon Mar 14, 2022 2:43 am

Your site might be hacked. This is a VERY likely reason in such case.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by websiteworld » Mon Mar 14, 2022 2:48 am

Not likely and it was doing this in the sandbed before it even went live.

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by thekrotek » Mon Mar 14, 2022 3:12 am

websiteworld wrote:
Mon Mar 14, 2022 2:48 am
Not likely and it was doing this in the sandbed before it even went live.
As you please. Check the DB optimization then.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by websiteworld » Mon Mar 14, 2022 3:28 am

I optimized the OC_Customer table and it's twice as fast. Still slower than I'd like, but much better at about 4 seconds. Thanks.

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by halfhope » Mon Mar 14, 2022 6:05 am

websiteworld wrote:
Mon Mar 14, 2022 3:28 am
I optimized the OC_Customer table and it's twice as fast. Still slower than I'd like, but much better at about 4 seconds. Thanks.
Hi.
You need to profile the SQL authorization request using EXPLAIN. Perhaps simple or composite indexes will solve this problem.

My FREE extensions in marketplace. [ security | flexibility | speedup ]


User avatar
Active Member

Posts

Joined
Tue Dec 10, 2013 9:44 pm
Location - San Diego

Post by JNeuhoff » Mon Mar 14, 2022 5:58 pm

We have an OpenCart site with more than 50 000 customers, and it only takes a fraction of a second to do a login.
Something else must have gone wrong on your website.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by websiteworld » Mon Mar 14, 2022 6:42 pm

We ran maintenance on the customer tables in MYSQL admin and that seems to have resolved it.

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by paulfeakins » Tue Mar 15, 2022 12:17 am

Check against this list of possible reasons: https://www.antropy.co.uk/blog/how-to-s ... ed-issues/

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by websiteworld » Thu Mar 17, 2022 3:24 am

paulfeakins wrote:
Tue Mar 15, 2022 12:17 am
Check against this list of possible reasons: https://www.antropy.co.uk/blog/how-to-s ... ed-issues/
Great post-
https://www.antropy.co.uk/blog/opencart ... very-slow/

I can remember reading about creating the indexes years ago, and had forgotten about that. I've been using OC since 1.5. Are all the recommended ones up to date for OC3.x? We don't have a table called product_tag anymore.

On a side note, I noticed you had mentioned Nitrocache when we used in OC2.0 which they retired. I installed DatabaseSpeed up and used MemCached with it, I think it works pretty well! https://isenselabs.com/products/view/da ... ed-booster

I noticed there were no indexes for the customer table, should those have indexes too? That seems like it would affect the customer login times.

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by IP_CAM » Sat Mar 19, 2022 3:39 am

You could try this one, to possibly get some better results:
https://github.com/IP-CAM/Optimize-Data ... .3.x-v.3.x

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by websiteworld » Sat Mar 19, 2022 3:56 am

IP_CAM wrote:
Sat Mar 19, 2022 3:39 am
You could try this one, to possibly get some better results:
https://github.com/IP-CAM/Optimize-Data ... .3.x-v.3.x
How do we know if it's safe? What exactly is it doing? Here is the code:

Code: Select all

<?php
class ControllerExtensionModuleDboptim extends Controller {
	public function index() {
		$data = array();
		
		$result = $this->db->query('show tables');
		$data['tables'] = array();
		
		foreach ($result->rows as $row) {
			$data['tables'][ $row[key($row)] ] = null;
		}
		
// 		if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($_POST['optimize']) && is_array($_POST['optimize']) && ! empty($_POST['optimize'])) {
// 			foreach($_POST['optimize'] as $table) {
					foreach ($data['tables'] as $table => $value) {
						$result = $this->db->query('optimize table '. $table);
						
						$data['tables'][$table] = $result->rows[0]['Msg_text'];
					}
// 			}
// 		}
		
		$this->load->language('extension/module/dboptim');
		
		$this->document->setTitle($this->language->get('heading_title'));
		
		$data['breadcrumbs'] = array();

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_home'),
			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
		);

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_extension'),
			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true)
		);

		if (!isset($this->request->get['module_id'])) {
			$data['breadcrumbs'][] = array(
				'text' => $this->language->get('heading_title'),
				'href' => $this->url->link('extension/module/dboptim', 'user_token=' . $this->session->data['user_token'], true)
			);
		} else {
			$data['breadcrumbs'][] = array(
				'text' => $this->language->get('heading_title'),
				'href' => $this->url->link('extension/module/dboptim', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'], true)
			);
		}
		
		if (!isset($this->request->get['module_id'])) {
			$data['action'] = $this->url->link('extension/module/dboptim', 'user_token=' . $this->session->data['user_token'], true);
		} else {
			$data['action'] = $this->url->link('extension/module/dboptim', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'], true);
		}

		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true);

		
		$data['header'] = $this->load->controller('common/header');
		$data['column_left'] = $this->load->controller('common/column_left');
		$data['footer'] = $this->load->controller('common/footer');

		$this->response->setOutput($this->load->view('extension/module/dboptim', $data));
	}
	
	protected function validate() {
		if (!$this->user->hasPermission('modify', 'extension/module/dboptim')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		return !$this->error;
	}
}

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by straightlight » Sat Mar 19, 2022 4:31 am

A bit pointless having to constantly optimize database tables that way ...

In addition, is_array lookup should be used after the !empty, not reversed and isset would not be needed in there.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by OSWorX » Sat Mar 19, 2022 11:31 am

websiteworld wrote:
Sat Mar 19, 2022 3:56 am
How do we know if it's safe? What exactly is it doing? Here is the code:

Code: Select all

<?php
class ControllerExtensionModuleDboptim extends Controller {
	public function index() {
		$data = array();
		
		$result = $this->db->query('show tables');
		$data['tables'] = array();
		
		foreach ($result->rows as $row) {
			$data['tables'][ $row[key($row)] ] = null;
		}
		
// 		if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($_POST['optimize']) && is_array($_POST['optimize']) && ! empty($_POST['optimize'])) {
// 			foreach($_POST['optimize'] as $table) {
					foreach ($data['tables'] as $table => $value) {
						$result = $this->db->query('optimize table '. $table);
						
						$data['tables'][$table] = $result->rows[0]['Msg_text'];
					}
// 			}
// 		}
}
Beside the former comment: yes it's safe.
And what this code does:
Running a simple

Code: Select all

OPTIMIZE table

which is a native MySQL command.

on previous selected tables (in a form):

Code: Select all

$_POST['optimize']
btw: if you already switched your tables from MyISAM to InnoDB, the OPTIMIZE command is useless.

But it's funny to see "a well coded script" ..

At the beginning you get the tables with that:

Code: Select all

$result = $this->db->query('show tables');
later you check if something is coming from a form (here commented)

Code: Select all

if ($this->request->server['REQUEST_METHOD'] == 'POST'
and then you use this:

Code: Select all

foreach ($data['tables'] as $table => $value) {
(using the former query).

Generally it would be better (and faster) not to call each table, instead use the IN syntax on one call.
And please, not show tables should be SHOW TABLES (optimize the same).

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by halfhope » Sat Mar 19, 2022 6:05 pm

Hi!

You can use my script to optimize tables and add missing indexes to the database.

My FREE extensions in marketplace. [ security | flexibility | speedup ]


User avatar
Active Member

Posts

Joined
Tue Dec 10, 2013 9:44 pm
Location - San Diego

Post by straightlight » Sat Mar 19, 2022 9:22 pm

OSWorX wrote:
Sat Mar 19, 2022 11:31 am
websiteworld wrote:
Sat Mar 19, 2022 3:56 am
How do we know if it's safe? What exactly is it doing? Here is the code:

Code: Select all

<?php
class ControllerExtensionModuleDboptim extends Controller {
	public function index() {
		$data = array();
		
		$result = $this->db->query('show tables');
		$data['tables'] = array();
		
		foreach ($result->rows as $row) {
			$data['tables'][ $row[key($row)] ] = null;
		}
		
// 		if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($_POST['optimize']) && is_array($_POST['optimize']) && ! empty($_POST['optimize'])) {
// 			foreach($_POST['optimize'] as $table) {
					foreach ($data['tables'] as $table => $value) {
						$result = $this->db->query('optimize table '. $table);
						
						$data['tables'][$table] = $result->rows[0]['Msg_text'];
					}
// 			}
// 		}
}
Beside the former comment: yes it's safe.
And what this code does:
Running a simple

Code: Select all

OPTIMIZE table

which is a native MySQL command.

on previous selected tables (in a form):

Code: Select all

$_POST['optimize']
btw: if you already switched your tables from MyISAM to InnoDB, the OPTIMIZE command is useless.

But it's funny to see "a well coded script" ..

At the beginning you get the tables with that:

Code: Select all

$result = $this->db->query('show tables');
later you check if something is coming from a form (here commented)

Code: Select all

if ($this->request->server['REQUEST_METHOD'] == 'POST'
and then you use this:

Code: Select all

foreach ($data['tables'] as $table => $value) {
(using the former query).

Generally it would be better (and faster) not to call each table, instead use the IN syntax on one call.
And please, not show tables should be SHOW TABLES (optimize the same).
Nowhere to be said it wasn't safe. What was said in there is that running the script such ways would be pointless.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by websiteworld » Sat Mar 19, 2022 9:41 pm

paulfeakins wrote:
Tue Mar 15, 2022 12:17 am
Check against this list of possible reasons: https://www.antropy.co.uk/blog/how-to-s ... ed-issues/
For future reference adding indexes solved my issue. The site is lightning fast now! Product_tag was skipped in my case.

Code: Select all

ALTER TABLE `category` ADD INDEX ( `parent_id` );
ALTER TABLE `category` ADD INDEX ( `top` );
ALTER TABLE `category` ADD INDEX ( `sort_order` );
ALTER TABLE `category` ADD INDEX ( `status` );
ALTER TABLE `option` ADD INDEX ( `sort_order` );
ALTER TABLE `option_description` ADD INDEX ( `name` );
ALTER TABLE `option_value` ADD INDEX ( `option_id` );
ALTER TABLE `option_value_description` ADD INDEX ( `option_id` );
ALTER TABLE `order` ADD INDEX ( `customer_id` );
ALTER TABLE `product` ADD INDEX ( `model` );
ALTER TABLE `product` ADD INDEX ( `sku` );
ALTER TABLE `product` ADD INDEX ( `upc` );
ALTER TABLE `product` ADD INDEX ( `manufacturer_id` );
ALTER TABLE `product` ADD INDEX ( `sort_order` );
ALTER TABLE `product` ADD INDEX ( `status` );
ALTER TABLE `product_option` ADD INDEX ( `option_id` );
ALTER TABLE `product_option_value` ADD INDEX ( `product_option_id` );
ALTER TABLE `product_option_value` ADD INDEX ( `product_id` );
ALTER TABLE `product_option_value` ADD INDEX ( `option_id` );
ALTER TABLE `product_option_value` ADD INDEX ( `option_value_id` );
ALTER TABLE `product_tag` ADD INDEX ( `product_id` );
ALTER TABLE `product_tag` ADD INDEX ( `tag` );
ALTER TABLE `url_alias` ADD INDEX ( `query` );
ALTER TABLE `url_alias` ADD INDEX ( `keyword` );
ALTER TABLE `user` ADD INDEX ( `username` );
ALTER TABLE `user` ADD INDEX ( `password` );
ALTER TABLE `user` ADD INDEX ( `email` );

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by OSWorX » Sat Mar 19, 2022 9:48 pm

straightlight wrote:
Sat Mar 19, 2022 9:22 pm
Nowhere to be said it wasn't safe. What was said in there is that running the script such ways would be pointless.
Guess you have to buy new glasses .. ?!
websiteworld wrote:
Sat Mar 19, 2022 3:56 am
How do we know if it's safe? What exactly is it doing?
Please read better next time before wasting the space here.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by straightlight » Sat Mar 19, 2022 9:49 pm

websiteworld wrote:
Sat Mar 19, 2022 9:41 pm
paulfeakins wrote:
Tue Mar 15, 2022 12:17 am
Check against this list of possible reasons: https://www.antropy.co.uk/blog/how-to-s ... ed-issues/
For future reference adding indexes solved my issue. The site is lightning fast now! Product_tag was skipped in my case.

Code: Select all

ALTER TABLE `category` ADD INDEX ( `parent_id` );
ALTER TABLE `category` ADD INDEX ( `top` );
ALTER TABLE `category` ADD INDEX ( `sort_order` );
ALTER TABLE `category` ADD INDEX ( `status` );
ALTER TABLE `option` ADD INDEX ( `sort_order` );
ALTER TABLE `option_description` ADD INDEX ( `name` );
ALTER TABLE `option_value` ADD INDEX ( `option_id` );
ALTER TABLE `option_value_description` ADD INDEX ( `option_id` );
ALTER TABLE `order` ADD INDEX ( `customer_id` );
ALTER TABLE `product` ADD INDEX ( `model` );
ALTER TABLE `product` ADD INDEX ( `sku` );
ALTER TABLE `product` ADD INDEX ( `upc` );
ALTER TABLE `product` ADD INDEX ( `manufacturer_id` );
ALTER TABLE `product` ADD INDEX ( `sort_order` );
ALTER TABLE `product` ADD INDEX ( `status` );
ALTER TABLE `product_option` ADD INDEX ( `option_id` );
ALTER TABLE `product_option_value` ADD INDEX ( `product_option_id` );
ALTER TABLE `product_option_value` ADD INDEX ( `product_id` );
ALTER TABLE `product_option_value` ADD INDEX ( `option_id` );
ALTER TABLE `product_option_value` ADD INDEX ( `option_value_id` );
ALTER TABLE `product_tag` ADD INDEX ( `product_id` );
ALTER TABLE `product_tag` ADD INDEX ( `tag` );
ALTER TABLE `url_alias` ADD INDEX ( `query` );
ALTER TABLE `url_alias` ADD INDEX ( `keyword` );
ALTER TABLE `user` ADD INDEX ( `username` );
ALTER TABLE `user` ADD INDEX ( `password` );
ALTER TABLE `user` ADD INDEX ( `email` );
Not to forget to mention the database table prefixes that may differ between the users.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sat Mar 19, 2022 9:51 pm

OSWorX wrote:
Sat Mar 19, 2022 9:48 pm
straightlight wrote:
Sat Mar 19, 2022 9:22 pm
Nowhere to be said it wasn't safe. What was said in there is that running the script such ways would be pointless.
Guess you have to buy new glasses .. ?!
websiteworld wrote:
Sat Mar 19, 2022 3:56 am
How do we know if it's safe? What exactly is it doing?
Please read better next time before wasting the space here.
The question was answered as the posted code itself is not about safe / unsafe as replied from my previous post. I could add, however, that there's nothing wrong regarding the code practice nor code security other than to mention to use the: $this->request->post instead of using $_POST in OC which nobody did, so far.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 16 guests