⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

set_relation_n_n very slow



rdal

rdal
  • profile picture
  • Member

Posted 25 July 2012 - 20:42 PM

Hi,
I have medical system that runs with Code Igniter and Grocery CRUD.
I have a large set o drugs stored in drugs table, over than 10K.
I also have a set of patient prescriptions, and in each prescription I may have several drugs.

The problem occurs when I try to add a new patient prescription, because I use set_relation_n_n to let users add multiple drugs to a prescription, and as I said before my drugs table has over than 10K records. "Add screen" takes too long to load, and the browser launches a dialog that asks if we want to stop script or continue executing. After 3 dialogs like that, "add page" finally loads, with all drugs available to choose.

I have already tried to change indexes in drugs table, but no luck until now.
Is there a way to fix this issue?

Thanks in advance,
Rafael Donato.

xxaxxo

xxaxxo
  • profile picture
  • Member

Posted 26 July 2012 - 19:14 PM

10k rows is a bit large. The problem is not in groceryCRUD. The way things work now for you is that groceryCRUD queries your relational db and add's all those rows to the multiple select menu - you will have that problem whenever you try to load that amount of data into a simple select menu aswell.
I have 2 suggestions:
1: use callback input/edit field and try to make a simple input filed with a typeahead (suggestion) js (i'm not 100% sure what it's called i'm using gccrud with twitter bootstrap and in bootstrap it's called typeahead ) - also I'm not sure if it will speed up the things because most of those scripts usually require an array with elements to suggest when inputing which will also require a big query.
2: add an action that calls another function in your app that doesn't use groceryCRUD to add the drugs to the users when inputing them. Instead of querying the db before load , and trying to display all those 10k into the view - try querying the db multiple times but displaying only small parts of the data.

Hoergold2

Hoergold2
  • profile picture
  • Member

Posted 19 September 2012 - 15:17 PM

Hi,

I myself also found that the CRUD does not work usable enough (browser goes off for some time etc.) if I try to use the n:n-relation on something like "authors" to an "book".

There are many, many Authors in the Author-table (>60k), but just to e.g. edit a Book (looking up the related Authors like 1, 2 or 3 in the relation-table and then showing the names (better would be: being able to build something to show "Name, First Name" because many Authors have the same last Name)) should not consume so much time etc.

It seems every single Author is loaded somewhere in the background - and that is not neccesary and seems to be the problem.

Does anybody has an idea about that?

Thanks,
Martin