Slow site? Try adding an Index

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Slow site? Try adding an Index

Post by michael.p.larsen » Tue May 11, 2010 1:38 pm

Our site ground to a HALT when we hit about 600 [edit]simultaneous[/edit] users. I checked SQL to see what queries were running and found a TON of calls to the ac_Users table... ALL having the LoweredUserName column in the WHERE clause.

I checked the indexes on the ac_Users table and there was ONLY ONE for the UserId column!

I ADDED an index to the LoweredUserName column and literally watched the CPU utilization DROP INSTANTLY from 95% to 10%. :!: :!:

Moral of the story? ADD this simple solution and your site SHOULD speed up.
Last edited by michael.p.larsen on Wed May 12, 2010 11:00 am, edited 1 time in total.

User avatar
NC Software
AbleCommerce Partner
AbleCommerce Partner
Posts: 4620
Joined: Mon Sep 13, 2004 6:06 pm
Contact:

Re: IMPORTANT: Slow site? Try adding an Index

Post by NC Software » Tue May 11, 2010 1:50 pm

I agree, the typical rule of thumb is if a column is used in a WHERE clause, it should be indexed. I hope AC 8 will also use stored procedures.
Neal Culiner
NC Software, Inc.

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: IMPORTANT: Slow site? Try adding an Index

Post by michael.p.larsen » Tue May 11, 2010 1:52 pm

I've never heard that rule of thumb... but it's set in stone in my brain now! I love it! Thanks for sharing that.

User avatar
GrfxDan
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 82
Joined: Sat May 26, 2007 10:58 am
Location: Mt Zion, IL
Contact:

Re: Slow site? Try adding an Index

Post by GrfxDan » Tue May 11, 2010 9:03 pm

Micheal, forgive me for being ignorant on the matter but are you referring to 600 user accounts or 600 simultaneous users? Also, can you provide details on how to add an index to the LoweredUserName column?
Image

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Slow site? Try adding an Index

Post by jmestep » Wed May 12, 2010 6:26 am

Dan, this is done within SQL server. I just checked your store and the ac_User table has indexes on the username and loweredusername. At W2M, we run code to create indexes as a part of every site install. I believe there are other routines that are run periodically to optimize database performance.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: Slow site? Try adding an Index

Post by michael.p.larsen » Wed May 12, 2010 8:21 am

Dan - 600 simultaneous users. We have over 65,000 users in the ac_Users table.

Judy - Are those routines something you created, or did it come with Able? My default install didn't have an index on the LoweredUserName column.

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: Slow site? Try adding an Index

Post by michael.p.larsen » Wed May 12, 2010 8:24 am

Here is the SQL script to create the index:

Code: Select all

CREATE NONCLUSTERED INDEX [ac_Users_LoweredUserName] ON [dbo].[ac_Users] 
(
	[LoweredUserName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO

User avatar
GrfxDan
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 82
Joined: Sat May 26, 2007 10:58 am
Location: Mt Zion, IL
Contact:

Re: Slow site? Try adding an Index

Post by GrfxDan » Wed May 12, 2010 8:43 am

Thanks for the info Judy. The W2M staff takes very good care of my site and I appreciate it!
Image

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: Slow site? Try adding an Index

Post by michael.p.larsen » Wed May 12, 2010 8:53 am

Sounds like you are in good hands Dan.

On average, how many simultaneous users would you say you have? 10? 100? 1000?

Just curious.

User avatar
GrfxDan
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 82
Joined: Sat May 26, 2007 10:58 am
Location: Mt Zion, IL
Contact:

Re: Slow site? Try adding an Index

Post by GrfxDan » Wed May 12, 2010 9:02 am

At peak times I've probably got 30 users at a time. I've got a while before I have to worry about 600 simultaneous users.
Image

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: Slow site? Try adding an Index

Post by michael.p.larsen » Wed May 12, 2010 9:10 am

Sure. It's a good problem to have :-P

I like your site, btw. Great work!

User avatar
NC Software
AbleCommerce Partner
AbleCommerce Partner
Posts: 4620
Joined: Mon Sep 13, 2004 6:06 pm
Contact:

Re: Slow site? Try adding an Index

Post by NC Software » Wed May 12, 2010 11:23 am

Michael,

What's the URL to your store? I'd love to check it out.
Neal Culiner
NC Software, Inc.

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: Slow site? Try adding an Index

Post by michael.p.larsen » Wed May 12, 2010 11:43 am

Neal - I don't link to the site from here for security reasons. I PM'ed you instead.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Slow site? Try adding an Index

Post by jmestep » Wed May 12, 2010 5:16 pm

Michael- they were routines that W2M created.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply