Do you put your indexes in the original control?

And how do you keep them in sync between test and production environments?

When it comes to database table indexes, my philosophy is that they are an integral part of writing any code that queries the database. You cannot enter new queries or modify a query without analyzing the effect on indexes.

Therefore, I try to keep my indexes synchronized between all of my environments, but to be honest, I'm not very good at automating this. This is a kind of random, manual process.

I periodically analyze index statistics and delete unnecessary indexes. I usually do this by creating a delete script, which I then copy back to other environments.

But in some places indexes are created and deleted outside the normal process, and it is very difficult to see where the differences are.

I found one that really helps is to use simple, numeric index names, for example

idx_t_01
idx_t_02

where t is the short abbreviation for the table. I find that index maintenance is not possible when I try to get smart with all the columns involved, e.g.

idx_c1_c2_c5_c9_c3_c11_5

It is too difficult to distinguish between such indices.

Does anyone have a really good way to integrate index maintenance into source control and development life cycle?

+3
source share
9 answers

, , . QA , .

.

+11

. " ", , , , , .

: - X . - script (), . - .

, . , , .

.

+6

, DML DDL , activerecord . , , , , .

, ( , ). , ( sysobjects db, ), , . tablename_col1_col2.

, sysobjects, ( , wayyyy dBMS, , , ).

+5

, : / . .

Java, , Ruby on Rails . , RoR, - "". , , 001_add_foo_table.rb, 002_add_bar_table.rb, 003_add_blah_column_to_foo.rb .. Ruby , , "" "". "" , , . , "" . , Rails , , , .rb, ( ) .

, .

Rails, , . , SQL DDL , 001_UP_add_foo_table.sql 001_DOWN_remove_foo_table.sql. - , , .

+1

, script .; -)

Index-:

  • IX_CUSTOMER_NAME "" ""
  • PK_CUSTOMER_ID ,
  • UI_CUSTOMER_GUID, GUID- , ( "UI" - ).
0

SQL (DDL, DML ..). , . .

0

, , . , .

, , .

0

- ( pg_dump -c, ddl ) script, , , , //, . , , QA , . , .

0

Using the grails application indexes are stored in the source element by default, because you are defining an index definition inside the file representing your domain object. Just offering the prospect of Grails as FYI.

0
source

Source: https://habr.com/ru/post/1697714/


All Articles