1

So I have only 1 model and 10 tables for example, I want to bring all the data from the tables into my 1 model, so I can use the Grid/Crud search/paginator etc.

If I use setSource on the grid (and not setModel), I lose pagination, quick and advanced search.

Note: Tables have no relations between them (they just have the same columns and different data) and we are talking about millions of records. Tried custom unions with DSQL but it's really slow and I have no paginator in the grid.

Any ideas ?

Ryko
  • 11
  • 3
  • It so happened that we're working on a very similar problem for one of our projects. I'm doing some experimenting today and will post some suggestions on how to solve this. – romaninsh Jan 28 '16 at 16:03
  • Thanks Romans, I'm waiting for your reply. My temporary solution is to get all the data from all the 10 tables and insert them into 1 table for which I have the model and use deleteAll() before insertions, but I don't think it's reliable if we talk about 50-100 million records. – Ryko Jan 29 '16 at 08:04
  • Tested on 1 million records and the loading time is > 1 minute .. it's not a good solution. – Ryko Jan 31 '16 at 09:35
  • not an official reply just yet, but please find my Gist with some model-union implementation. It does work for me, but I still have to clean it up before setting up a proper add-on with documentation: https://gist.github.com/romaninsh/5f52b39d3d40e33d910e – romaninsh Feb 03 '16 at 10:39
  • Thanks a lot ! You should add it as an answer so I can checkmark. – Ryko Feb 24 '16 at 13:56

1 Answers1

0

Full support for UnionModel is now available as extension to Agile Data. It should easily combine 10 other models, align fields, offer you grouping support, pagination, conditions and other features you expect from a regular model.

UnionModel will automatically drop conditions, limit and aggregation down to the individual model level to make the query optimal.

More details about UnionModel are here:

http://www.agiletoolkit.org/data/extensions/report

Source: http://GitHub.com/atk4/report

Agile Data is now a separate framework, but it can be used with Agile Toolkit, you simply need to switch to branch 4.4.

If you prefer not to use this extension, you would have to manually create expression and align sub-query fields yourself.

romaninsh
  • 10,606
  • 4
  • 50
  • 70