osC-Explain v1.0 for osCommerce-MS2

by Chemo

What does this contribution do?

This contribution adds the ability to store the EXPLAIN data return for each query that is executed on an osC store. In addition, the included admin report provides excellent functionality to view the data in a coherent format.  This is the tool that I use to optimize client sites and have decided to release it to the osC contribution coder community.  We're all coders...this one I'm going to make an open call to all of you to make improvements and upload back to the contribution area.  This one is by the coders and for the coders.  I encourage each of you to make this a more feature rich contribution so we can all benefit.

Features:

How does this contribution work?

This contribution first verifies that EXPLAIN_QUERIES is true and then uses simple criteria to determine whether to store the query.  Once a query is flagged to be EXPLAINED it will stored in the `explain_queries` table.  Queries can be EXPLAINED and stored for single pages, groups of pages, or site wide.  Very flexible in storage criteria.

Once enough data is collected (I recommend at least a 1:10 ratio of unique:total) use the report to view and export the data.

Screenshots

Main Explain Queries report - click to see full sized image

CVS data export - "Save As" dialog box (on my Linux box, Mozilla)

HTML data export - click to see full sized image

How do I install this contribution?

Upload 2 new files, modify 1 existing file, done. Install should take about 2 minutes.   I use this tool on client sites that I'm optimizing so the install is designed to be very fast and easy. As always, backup the files and database before you do anything.  If it breaks something and you don't have a backup don't come crying to me.

STEP 1 - Upload the included files

The files should be located in the upload directory of this contribution.

STEP 2 - Call *admin*/install-explain.php in your browser

This script has two options: install or uninstall. I think you can figure out what each does. Read the page.

STEP 3 - Edit *catalog*/includes/functions/database.php

Find the function tep_db_query()

REPLACE WITH THIS CODE:

STEP 4 - Edit *admin*/includes/boxes/reports.php

Add a link to the stats_explain_queries.php file. I'm not giving directions since I expect you to already know how to do this. If you don't know how please uninstall this contribution.

STEP 5 - Admin Control Panel -> Configuration -> Explain Queries

Set your options and let the table populate with data!

Notes

The installation is pretty straight forward. The target audience for this contribution are coders, developers, and advanced webmasters that know what the hell they are doing.  Thus, if you are clueless and can't figure it out and/or correct the install problem please email: blackhole@mesoimpact.com

Support

osCommerce is a community driven organization and as such the support base will fall entirely on the [coder and developer] forum members. The code is thoroughly commented and should be easy to follow for any coder. I offer limited support in-between paid projects (feeding my family comes first before volunteer time).

If you use this contribution and find it useful a small donation can be made via PayPal.  If you're a coder, designer, or webmaster and would like to contract me for site analysis or custom coding please email me with the link at the top of this page.  Thank you for your support!

Enter Donation amount: $

Credits

This contribution is original work. Enjoy!