S
S
Semyon Dubina2014-01-16 11:48:11
PostgreSQL
Semyon Dubina, 2014-01-16 11:48:11

How to deal with postgresql table partitioning in YII framework?

The architecture of the table is as follows: I break the table of media data by type (video, text, audio). I want only to read from the general table, and to write in splits. I did not master the creation of an adequate model for the task, i.e. rendered the common table into the modules and into the partition submodules, the views do not work at the same time - eternal database errors, although direct queries work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Semyon Dubina, 2014-01-22
@sam002

I solved the issue like this:
1) all models in one module (both the main table and its partitions)
2) for models (video, audio, text) created new actions with views through $this->renderPartial(MY_VIEW)
3) customized for different view sources (for example, for video: youtube, vimeo)
4) for editing I call from the view for the main table:

$this->beginClip('content');
    Yii::app()->runController('MODULE_NAME/'.$data->type.'/ACTION/id/'.$data->id);
$this->endClip('content');
echo $this->clips['content'];

In the main controller, I have both display (directly from the main table) and editing through calls to split controllers.
As such, views of the main table without recourse to partitions are not used, because customization is required for each type, but in such a simple way I do a convenient enumeration. To speed up the first 100 records of the partition, I cache (I’m still building indexes, by itself), and I sort the selection from the main table by data type and request it immediately with an array.
PS: now I will finish the project part and will study query optimizations in yii in detail, otherwise the whole base will fall when selecting with filtering...

C
cat_crash, 2014-01-16
@cat_crash

Look aside beforeSave and afterFind for the data model.
More clearly here www.yiiframework.com/doc/blog/1.1/en/post.create

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question