For better performance in the PostgreSQL database is it better to have the products split into smaller tables?

0

Hello,

I am developing a system to manage the sale of various real estate developments. In this system each venture has a group of units available, type "Apt 21 - 2nd Floor, Apt 34 - 3rd Floor" etc.    I need performance for the broker to access a unit, see its information and even change the selling situation of that unit. Ex: from available to sold.   As the same builder has several projects and I work with the same system several builders; the system has registered in the same table the units of many enterprises having a field "emprendimento_id" as identifier of which enterprise it is part to be used with filter in the sales mirror. So far so good.    I previously used a "sales mirror" table with all units, but over time the amount of developments was growing, the table also started to get slow access and change information of a unit. So I started using a table for each venture. But with this difficult global sales performance queries in general and a broker sells more than one venture and with that makes it difficult to consult your sales overall since they are distributed in several tables. I have no problem creating queries to fetch the information by crossing multiple tables and gathering for the query. But I would like to know if I am correct in using one table per enterprise, or should I have left all units in the same indexed by the enterprise id?

    
asked by anonymous 16.07.2018 / 20:14

2 answers

0

I think it gets better organized. In my view, you should create 4 tables: builder, enterprise, block and apartment. The sold flag must be placed for apartment. A join between these tables you could bring the list of apartments sold, with its block, venture and construction company. But of course, that for you to create the MER needs to stay well understood the business rule! Always make the primary and foreign key be number and in case N fields are used for filter use indexes! In a second moment, you can think of tunning (by touching the environment variables of postgresql.conf)

    
16.07.2018 / 20:44
0

In this case the identity of the tables is very important. For when doing the relationships with the index will help in the performance.

    
20.07.2018 / 23:58