Too many queries [SOLVED]

Status
Not open for further replies.

DarkFire

New Member
I'm currently working on designing a form/table for my website.
Upon designing the table I noticed that the site seemed a litle slow, so I activated debug mode to check for any errors/unnecesarry queries. And it didn't take too long for me too locate the problem.

Fabrik alone generated 484 queries. :eek: 337 of those queries look like this:
Code:
SELECT *
FROM jos_fabrik_tables
WHERE id = '1'
This is when viewing a table i've created in fabrik, and the table only contains two records.
I'm using fabrik 1.0.4

My question now is why are it generating all this similar queries and how do I get rid of most of them? ???
 
Re: Too many queries

wow thats odd, Fabrik is query intensive and there are some things that could be improved on it, but I dont see that select * being run so many times (on a table that generates 100 sql queries I have 3 of those select * queries ), do you have an example of the page so I can take a look?
 
Re: Too many queries

This is one strange problem....
I have now completly reinstalled fabrik and made the table and form again from scratch,
in the hope that I maybe had selected some wrong options.
But it didn't help and I still have a huge number of queries.

The new table is now at
http://www.darkfire.ws/nck/index.php?option=com_fabrik&Itemid=81

Update:
I have now tried to downgrade too Fabrik 1.0.2
This version does not produce the same amount of queries
It now only repeats about 15 similar queries and total queries are down to about 115 for Fabrik alone
Thats something thats much more acceptable :)
 
Re: Too many queries

Reading trough the source code and commenting out lines i've managed to mostly remove the problem

All the changes was done in fabrik_table.class.php

The first line commented out who fixed the problem was nr 3019
Code:
$total = $this->getTotalRecords( $fabrikDb, $aData );

Following the program onwards i found the line 3081 was causing the problem
Code:
$cond 		= $this->getFilterConditionSQL( $aData );

And finally too line 414
Code:
if( $this->_oForm->hasElement($key)){

Removing line 414 removes the problem, unfortunatly I don't know what its purpose is.
The line is in the getFilterConditionSQL function.
Have no idea why that line would cause any of the problem tough.

It now uses about 30 similar queries.
 
Re: Too many queries

Hi

I'll try to explain the different queires:

Code:
$total = $this->getTotalRecords( $fabrikDb, $aData );

This should run one sql query to count the number of records in the table.

Code:
$cond 		= $this->getFilterConditionSQL( $aData );

This gets the part of the sql query that filters the table data based on the selected filters.

Code:
$this->_oForm->hasElement($key)

This checks that the form actually contains an element that matches the key fabrik is trying to filter on.
On your page i see the sql being repeated but not on my test pages here. I dont think register globals would effect that. Do you have the table mambot installed as well?

Cheers
Rob
 
Re: Too many queries

I've made a new fresh seperate install of joomla with only fabrik installed now.
I've added a simple form with four elements and a table view.
Each time I add/publish a new element it runs an increasing number of queries
(367 queries for 4 elements). Unpublishing them again decreases number of queries.
Not running any table mambots.
 
Re: Too many queries

each element you display will increase the number of queries, as each element loads in its own validations, javascript code, etc.
However, if I look at a table with 18 or so rows I have 192 queires run, this is using the code from the SVN.
If you can could you try checking out the code from there and see if that still gives you so many queries

Cheers
Rob
 
Re: Too many queries

Installed the latest version from SVN and still producing strange results.
Tried tracking the code path a litle further and ended up with this.
Please correct me if i've gotten this completly wrong somewhere.... ::)

In fabrik_groups.class.php it runs this code to get the db table name
Code:
$tableName = $oForm->getTableName();

The function getTableName() checks if $this->_table is not an object
(In my case its apparently not an object, its doesn't contain any data at all ???)
It then tries to create a table object
Code:
$this->_table = $this->loadTable( $this->table_id );

It will now run this function to get the desired effect
Code:
	function loadTable( $tableId ){
		global $database;
		$oTable = new fabrikTable( $database );
		$oTable->load( $tableId );
		return $oTable;
	}


This code is run four times when the function hasElement is run
(called from fabrik_table.class.php line 427, and this again is called several times)
Summing it up, that creates a lot of extra queries for every extra element that is published

Pål
 
Re: Too many queries

Problem is finally solved (I hope) ;D

Still don't know the cause of all this tough. For some reason it never saved
the _table variabel in the fabrikForm class after returning the getElementFullName. :-\
Next time it made the loop the _table variabel was empty and it had to recreate the object again.

Added this to the top of the hasElement function
Code:
if (!is_object($this->_table)) {
	$this->_table = $this->loadTable( $this->table_id );
}
thus making the object a bit earlier than intended.
Hopfully it won't affect any other functions in the code.

Pål
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top