-3

We have a cartesian product and currently we are storing in a single table and this table is growing drastically and user can perform update and read operations on these entities and we have a soft delete when user deletes the record. And now we are getting hit by performance issues for read and update operations. Basically this cartesian product holds permissions for different roles and categories.

Wanted to know if anyone came across the similar situation and understand the best practices to store the cartesian product.

I was also thinking to split this into N table and then write and update individually for each type and then while reading perform a join.

So what are the best practices to store a cartesian product.

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171
Hafeez Khan
  • 427
  • 2
  • 6
  • 22
  • 1
    Did you forget to ask a question? – Sean Lange Sep 28 '18 at 19:48
  • 1
    The typical practice for a database that supports an [OLTP](https://searchdatacenter.techtarget.com/definition/OLTP) is to store data in normalized form, which precludes storing Cartesian products. However for a data mart or warehouse it is very common to store a Cartesian product (e.g. "cubes"). It depends on what your database is for and what you wish to optimize for. – John Wu Sep 29 '18 at 02:14

1 Answers1

1

Cartesian product simply mean product of two tables, otherwise its just a table and not a Cartesian product, so of course it should be split and whenever needed, the Cartesian product can be produced from these 2 tables.

Imagine that Table1 and Table2 each has 1000 records, a Cartesian product of these 2, will have 1000000 records, the records that can simply be produced from these 2000 records.

And of course using conditions, you may produce only a portion of the Cartesian product that you need and not all of it.

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171