国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? Java java?? ?? pg-index-health – PostgreSQL ??????? ?? ?? ?? ??

pg-index-health – PostgreSQL ??????? ?? ?? ?? ??

Jan 06, 2025 pm 06:20 PM

?????!

2019??? ?? ?????? ??? ???? ???? ??? ???? pg-index-health?? ?? ?? ??? ??? ????. ?? ?? ? ???? ? ??? ??? ??????? ?? ???? ??????.

??? ?? pg-index-health? ???? ???????. 2024??? ?? ???? ??? ?? ?? "???"? ??? ???? ????? ??? ??? ??? ??? ??????.

???????? ??? ?? ??????? ??

?? 2015??? PostgreSQL? ??? ??? ? ???? ??? ?????? ??? ? Tensor?? ???????.

2015??? ??? ??? ??????? ??? ???? ?? ??? ??????. ????? ??? ?????? ??? ????? ?? ?? ??? ??? ?? ???? ?? ???? ?? ??? ??????. ?? ???? ????? ????? ?? ????? ???? ??? ?? ??????.

????? ???? ???????? ???? ??????.
?????? ?? ?? ?????, ??? ? ?????? ?? ??? ?? ??????. ?? ? ?? ?? ??????? ??? ????? ???? ??????. ???? ?? ??? ??? ???? ?????? ?? ??? ? ????? ?? ???? ???? ???? ??????.

??? ????? ? ??

??? ????? ?? ???? ??? ?? ????. ????? ?? ???? ?? ??? ??? ?? ??? ???? ??? ????. ??? ??? Martin Fowler? ?? ??????.

pg-index-health – a static analysis tool for you PostgreSQL database

???????? ?? ?? ???? ??? ??? ????? ??? ?? ?????. ??? ??? ?? ????? ??(Docker, Testcontainers)? ??? ?? ???????. ??? ??? ????? ? ?? ????? ????. ?? ??? ??? ?? ? ????. ?? ? ??? ??? ??? ??? ???? ????.

pg-index-health – a static analysis tool for you PostgreSQL database

?? ??? ?? ?? ??? ??? ?? ?? ???? ??? ?? ???? ????? ???? ?? ??? ???? ?? ?? ? ?? ???? ?? ??? ???? ????.

?? ????? ?? ???? ?? ??? ??????. ? ???? ???? ??? ????? ??? ?? ?? ??? ????.

?? ?? ??? ???

Java ? Kotlin ??? ?? ?? ??? ?? ???? ?????. Kotlin ???? ?? ????? ???? ??? decekt???. Java ??????? ?? ?? ??? ??(?? Linter??? ?)? ??? ? ????. ?? ???? Checkstyle, PMD, SpotBugs, Error Prone ?? ????. ?? ?? ??? ??? ?? ???? ???? ? ????.

?? detekt? Checkstyle ?? ?? ??? ???? ????? ?? ?? ??? ?????.

?????? ??????? ?? ?? ??

?? ????????? ?????? ??? ?? ?????? ??? ???? ?????? ?? ?????? ??????? ???? ??? ????.

Java ????? ??????? ???? ?? ??? Liquibase? Flyway???. ?????? ??? ?? ?? ?? ??? ?? ?????? ? ?????? ???. ?????? ??? ???? ?? ???? ?????? ?? ?? ??? ?? ??? ????? ??? ??????? ???? ???.

?? SQL? ??????? ???? ?? Liquibase? ?? XML ?? ??? ??? ?? ?? ??? ???? ???? ??? ????? ?? ?????. ?? ???? ? ?? "?? ????? PostgreSQL ??? ?? 6?? ?"?? ??????.

SQL ?????? ?? ??

???????? SQL ??? ????? ????? SQL? ???? Checkstyle? SQLFluff? ???? ?? ????. ? ??? ?? ??????? ??(PostgreSQL ??)? ???? CI ?????? ??? ? ????. 60? ??? ??? ?? ??? ??? ???? ??? ? ? ??, SQL ?? ?/??? ??, ????, ??? ? ?? ?? ?? ??? ? ????.

??? ?? ??? ??? ?? ??? ?????.

-- well-formatted SQL
select
    pc.oid::regclass::text as table_name,
    pg_table_size(pc.oid) as table_size
from
    pg_catalog.pg_class pc
    inner join pg_catalog.pg_namespace nsp on nsp.oid = pc.relnamespace
where
    pc.relkind = 'r' and
    pc.oid not in (
        select c.conrelid as table_oid
        from pg_catalog.pg_constraint c
        where c.contype = 'p'
    ) and
    nsp.nspname = :schema_name_param::text
order by table_name;
-- poorly formatted SQL
SELECT pc.oid::regclass::text AS table_name, pg_table_size(pc.oid) AS table_size
FROM pg_catalog.pg_class  pc
JOIN pg_catalog.pg_namespace AS nsp
ON nsp.oid =  pc.relnamespace
WHERE pc.relkind = 'r’
and pc.oid NOT in (
  select c.conrelid as table_oid
  from pg_catalog.pg_constraint   c
  where    c.contype = 'p’
)
and nsp.nspname  = :schema_name_param::text
ORDER BY  table_name;

? ??? SQL ??? ?? ????? ?? ????. ?? ??? ?? ?? ?? ??? ?? ??? ?? ?? ??? ? ?? ??? ??? ???? ????. SQLFluff? ??? ???? ???? ??? ?????.

SQLFluff ??

?? ???? ??? ??? ??? ????.

pg-index-health – a static analysis tool for you PostgreSQL database

?? SQLFluff? select ??? ?? ? ?? ??? ??? ??? ??????. ? ??? ?? ???? ?? ?? ?? ????. ??? ?. ? ?? ?? ?? ??? ??? ? ?????. ?? ??? ?? ??? ?? ?? ??? ?????. ? ??? join ?? ?? ?? ??? ???????. ?? ??? ???? ???? ?? ?????.

?? ?? SQLFluff? ? ?? ?? ??? ? ?? ?? ????? one, two? ?????.

?????? ???? ?????? ?? ??

?????? ??? ??? ??? ? ????. ??? ?????? ??? ?? ?????. ??????? ?? ? ????. ??? ??????? ?? ??????? ??? ??? ?? ????. ????? ??? ?? ???? ??????? ?? ??

? ? ??? ????.

?? ??? ??

PostgreSQL(?? ?? ??? ??????? ?????)? ?? ??? ?? ?? ??? ?? ?????? ???? information_schema ???? ??? ?????. information_schema? ?? ??? ???? ??, ?? ?? ???? ??? ??? ? ????(??? ?? SchemaCrawler? ???? ?????).

PostgreSQL?? ????? information_schema ?? ?? ??????? ?? ??? ?? ?? ? ?? ??? ???? ??? ????(pg_catalog ???)? ??? ? ????.

???????

????? ??? PostgreSQL? ? ??????? ??? ?? ??(?? ??? ?????, ??? ?????, ?? ??? ??? ????? ?)? ?????. ?? ?? ???? ??? ?????. ? ??????.

??? ??? ?? ??? ??? ???? ?? ??? ????? ???? ???? ??? ??? ? ????.

  • ???? ?? ???? ?????.
  • ??? ???? ??? ???? ?????.

??? ???? ???? ? ????. ??? ??? ??? ??? ???? ?????. ??? ??? ? ??? ??? ????? ?? ???? ?? ?????. ?? ?? ?/??/?? 1? ???? ???? ??? ?? ?? ??? ??? ??? ???? ??? ???? ???.

?????? ????? ???? ?? ??? ? ????? ????? ???? ???? ??? ???? ????.

pg-index-health? ? ??

??? ??? ??? ?????? ?? ?? ?????? ???? ?????? ??? ????? ????? ?? pg-index-health?? ?? ??? ??????.

? ????? ?? ?? ??? ???? ????.

  • ??? ???? ??? SQL ?? ??? ?? ?????(?? 25?? ??? ???? ??). ??? Java ??????? ???? ?? ????? ??? ??? ?????? ???? ? ????.
  • ??? ?? — ?? ??? ??? ???? ???? ??? ?????.
  • ?? ???? ??? ?????? ????? ???? ?? HighAvailabilityPgConnection ???.
  • SQL ??? ???? ??? ??? ?? ??? ????? ???????.
  • ??/????/?? ???? ??? ???? ??? ???? ?? Spring Boot ??????.
  • ??? ??? ?? ?? SQL ??????? ??? ? ?? ?????? ???

?? ??

?? ??(?????? ?)? ? ???? ????.

  • ??? ??(?? ??)
  • ?? ??(??? ???? ??).

??? ??

??? ??? ????? ??? ?????? ?????? ??? ?? ??? ????. ??? ???? ??? ??? ???? ????? ?? ????? ? ???? ?????.

??, ??, ??? ???? ? ?? ???? ??? ?????? ????? ??? ?????. ?? ???? ??? ????? ?? ????? ???? ?? ??? ?? ??? ?????? ?? ?? ??? ?????. ??? ??? ?? ??? ???? ?? ??? ?? ??? ???? ??? ??? ??? ????? ?? ????? ???? ????.

pg-index-health – a static analysis tool for you PostgreSQL database

?? ????? PostgreSQL??? ??? ? ????? ??? ???? ???? ???? ???? ????. ??? ?? ???? ??? ?????? ???? ??? ??? ?? ??? ? ????. ???? ???? ??? ???? ????? ????? ? ???? ?? ??? ???? ??? ???? ???.

?? ??

?? ???? ??? ??? ???? ??? ?????? ?? ? ?? ?? ????? ??? ? ????. ?? ????? ???? ?? ?? ???? ???????? ??? ?? ????. ??? ???? ??? ???? ?? ???? ???? ??? ???? ???? ? ??? ??? ???? ?? ?????.

pg-index-health – a static analysis tool for you PostgreSQL database

pg-index-health? ???? ??

pg-index-health? ?? ?? ??? ??? ?????? ?????? ??? ???? ?? ???? ???? ????.

Spring Boot ??????? ?? ??? ???? ???? ???? ???.

-- well-formatted SQL
select
    pc.oid::regclass::text as table_name,
    pg_table_size(pc.oid) as table_size
from
    pg_catalog.pg_class pc
    inner join pg_catalog.pg_namespace nsp on nsp.oid = pc.relnamespace
where
    pc.relkind = 'r' and
    pc.oid not in (
        select c.conrelid as table_oid
        from pg_catalog.pg_constraint c
        where c.contype = 'p'
    ) and
    nsp.nspname = :schema_name_param::text
order by table_name;

?? ?? ?? ???? ?????.

-- poorly formatted SQL
SELECT pc.oid::regclass::text AS table_name, pg_table_size(pc.oid) AS table_size
FROM pg_catalog.pg_class  pc
JOIN pg_catalog.pg_namespace AS nsp
ON nsp.oid =  pc.relnamespace
WHERE pc.relkind = 'r’
and pc.oid NOT in (
  select c.conrelid as table_oid
  from pg_catalog.pg_constraint   c
  where    c.contype = 'p’
)
and nsp.nspname  = :schema_name_param::text
ORDER BY  table_name;

? ?????? ?? ??? ?? ??? ???? ?????. ?? ?? ??????? ??? ????? ??? ?? ??????? ?? ?? ??? ????? ?????.

?????? ? ???? ? ??? ????? ???. ?? ??????? ??? ? ??? ??? ???? ?????. ???? ?? ??? ???? ?? ????? ??? ???? ???. ?, ???????? ??? ????? ????? ???? ????.

?? ?? ? ?? ??

?? ?? ???? ????? pg-index-health? ???? ??? ? ??? ?? ???? ?? ?????. ?? ?? ??? ????? ??? ?? ?? ????. ?? ??, ?????? ??? ????? ?? ?? ???? ?????. PostgreSQL? ???? ?? ?? ?????? ??? ??? ??? ? ????. ????????? ??? ?? ? ????.

dependencies {
    testImplementation("io.github.mfvanek:pg-index-health-test-starter:0.14.4")
}

? ???? ??? ?? ??? ??? ?? ????. ? ?? ?? ?? ??(TABLES_WITHOUT_DESCRIPTION, COLUMNS_WITHOUT_DESCRIPTION, FUNCTIONS_WITHOUT_DESCRIPTION)? ??? ????.

?? ??? ??? ??? ? ????.

import io.github.mfvanek.pg.core.checks.common.DatabaseCheckOnHost;
import io.github.mfvanek.pg.core.checks.common.Diagnostic;
import io.github.mfvanek.pg.model.dbobject.DbObject;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class DatabaseStructureStaticAnalysisTest {

    @Autowired
    private List<DatabaseCheckOnHost<? extends DbObject>> checks;

    @Test
    void checksShouldWork() {
        assertThat(checks)
            .hasSameSizeAs(Diagnostic.values());

        checks.stream()
            .filter(DatabaseCheckOnHost::isStatic)
            .forEach(c -> assertThat(c.check())
                .as(c.getDiagnostic().name())
                .isEmpty());
    }
}

?? ??? ??? ?????.

create table if not exists demo.warehouse
(
    id bigint primary key generated always as identity,
    name varchar(255) not null
);

comment on table demo.warehouse is 'Information about the warehouses';
comment on column demo.warehouse.id is 'Unique identifier of the warehouse';
comment on column demo.warehouse.name is 'Human readable name of the warehouse';

pg-index-health? ??? ? ?????? ??? ?? ??? ??? ?? ???? ?? ?? ??? ?? ??? ? ????. ??? ??? ???? ??? ?????? ?? ??? ????. ??? ?? ??? ?? ??? ???? ?? ?? ????.

@Test
void checksShouldWork() {
    assertThat(checks)
        .hasSameSizeAs(Diagnostic.values());

    checks.stream()
        .filter(DatabaseCheckOnHost::isStatic)
        .filter(c -> c.getDiagnostic() != Diagnostic.TABLES_WITHOUT_DESCRIPTION &&
            c.getDiagnostic() != Diagnostic.COLUMNS_WITHOUT_DESCRIPTION)
        .forEach(c -> assertThat(c.check())
            .as(c.getDiagnostic().name())
            .isEmpty());
}

?? ?? ?? ???? ??? ?? ? ? ??? ???????.

?? ?? ?? ???

PostgreSQL? MVCC ????? ???? ?? ?? ?? ?? ?? ???(?? ???)? ??? ??? ??? ??? ?? ??? ??? ? ????. ?? ?? ?? ?? ?????? ?? ?? ?? ?? ??? ????? ?? ?? ?? ??? ? ????.

?????? ?? ??? ??? autovacuum ????? ?? ????? ??? ??? ??? ??? ????? ????. ???? ??? ??? ????? ??? ??? ??? ?? ?? ?? ?? ??? ??? VACUUM FULL ??? ???? ????. ?? ???? ?? ? ??? ?? ? ???? ???? ?? ?????? ?? ?? ??? ??????.

???? ?? ??? ??? ??? ???? ?? pg_repack? ?? ?? ?? ????? ???? ??? ????. pg_repack? ?? ?? ?? ? ??? ?? ???? ?? ? ?? ?? ??? ?? ??? ??? ????. TABLES_WITHOUT_PRIMARY_KEY ??? ?? ?? ?? ???? ???? ?? ?? ?? ??? ???? ? ??? ???.

??? ?? ?? ?? ???? ????. ? ???? bloat? ???? pg_repack? ?? ??? ? ?? ??? ?????.

-- well-formatted SQL
select
    pc.oid::regclass::text as table_name,
    pg_table_size(pc.oid) as table_size
from
    pg_catalog.pg_class pc
    inner join pg_catalog.pg_namespace nsp on nsp.oid = pc.relnamespace
where
    pc.relkind = 'r' and
    pc.oid not in (
        select c.conrelid as table_oid
        from pg_catalog.pg_constraint c
        where c.contype = 'p'
    ) and
    nsp.nspname = :schema_name_param::text
order by table_name;

??? ???

?? ??????? ???? ??? ????? ???? ??? ??? ?? ?????. Database-as-a-Service ???? ??? ? ??? ? ?? ?? ?????? ??? ?? ??? ??? ?? ??? ????.

???? ? ???? ????? ??? ??????. ??? ???? ?? ??? ?? ???? ????? ??? ?? ? ???? ??? ?????. ?? ??? ???? ?? ?? ???? ???? ?? ??? ????. ??? ???? ????? ???? ???? ??? ??? ??? ??? ?? ??? ???? ??? ???? ??? ??? ? ????. ??? ???? ??? ?? ?????? ??? ??? ????? ???? ???.

?????? ???? ???? ???? ???? ??? ?? ?????. ?? ?? ?? ?? ?? ??? ???? ?????. id ?? ???? ????? ?? ????? ????? ??? ?? ?? ?? ??? ????.

-- poorly formatted SQL
SELECT pc.oid::regclass::text AS table_name, pg_table_size(pc.oid) AS table_size
FROM pg_catalog.pg_class  pc
JOIN pg_catalog.pg_namespace AS nsp
ON nsp.oid =  pc.relnamespace
WHERE pc.relkind = 'r’
and pc.oid NOT in (
  select c.conrelid as table_oid
  from pg_catalog.pg_constraint   c
  where    c.contype = 'p’
)
and nsp.nspname  = :schema_name_param::text
ORDER BY  table_name;

??? ?? ????? ??? ??? ?????. unique ???? ?(?? ? ??)? ???? PostgreSQL? ???? ?? ?(?? ? ??)? ?? ?? ???? ?????. . ?? ???? ???? ??? ??? ????. ???? ???? ?????. ??? ?? ??? ??? ? ?? ???? ?? DUPLICATED_INDEXES ??? ?? ?? ??? ? ????.

-- well-formatted SQL
select
    pc.oid::regclass::text as table_name,
    pg_table_size(pc.oid) as table_size
from
    pg_catalog.pg_class pc
    inner join pg_catalog.pg_namespace nsp on nsp.oid = pc.relnamespace
where
    pc.relkind = 'r' and
    pc.oid not in (
        select c.conrelid as table_oid
        from pg_catalog.pg_constraint c
        where c.contype = 'p'
    ) and
    nsp.nspname = :schema_name_param::text
order by table_name;

???(????) ???

???? ???? ?? ?? ?? ?????. ?? ???? ???? ?? ?? ???? ? ??? ???? ??? ? ????. ?? ?? A, A B, A B C? ?? ?? ?? ???? ???? ????? ?????. ? ???? ?? ? ???? ? ?? ???? ?????? ?? ??? ? ????(? ???? ???? ?? ????). . ??? ?? ???? ???? ??? ??? ??? ??? ? ??? INTERSECTED_INDEXES ??? ??? ??? ????? ???????.

-- poorly formatted SQL
SELECT pc.oid::regclass::text AS table_name, pg_table_size(pc.oid) AS table_size
FROM pg_catalog.pg_class  pc
JOIN pg_catalog.pg_namespace AS nsp
ON nsp.oid =  pc.relnamespace
WHERE pc.relkind = 'r’
and pc.oid NOT in (
  select c.conrelid as table_oid
  from pg_catalog.pg_constraint   c
  where    c.contype = 'p’
)
and nsp.nspname  = :schema_name_param::text
ORDER BY  table_name;

???? ?? ?? ?

PostgreSQL??? ?? ???? ???? ?? ?? ? ?? ??? ??? ? ????. ?, ?? ???? ???? ????? ???? ???? ??? ???? ???? ????. ?? ???? ??? ??? ?? ?? ?? ?? ?? ???? ?? ?? ????. ??? ??? ?? ???? ??? ??? ?? ????.

?? ?? ???????(?? PostgreSQL 16.6? ???? ????).

dependencies {
    testImplementation("io.github.mfvanek:pg-index-health-test-starter:0.14.4")
}

orders ???? order_item ???? ????. order_id ?? ?? ?? ?? ?????. ?? ?? ?? ?? ? ?? ?? ?? ?? ??? ???? ?? ?? ??? ?? ?????.

???? ???? ??? ??? ??? ?????. 100,000?? ??? ?????. ??? 2? ???? ???? 1????.

import io.github.mfvanek.pg.core.checks.common.DatabaseCheckOnHost;
import io.github.mfvanek.pg.core.checks.common.Diagnostic;
import io.github.mfvanek.pg.model.dbobject.DbObject;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class DatabaseStructureStaticAnalysisTest {

    @Autowired
    private List<DatabaseCheckOnHost<? extends DbObject>> checks;

    @Test
    void checksShouldWork() {
        assertThat(checks)
            .hasSameSizeAs(Diagnostic.values());

        checks.stream()
            .filter(DatabaseCheckOnHost::isStatic)
            .forEach(c -> assertThat(c.check())
                .as(c.getDiagnostic().name())
                .isEmpty());
    }
}

ID=100? ??? ?? ??? ????? ?? 2?? ?? ????? ????? ???. ?? ???? id ?? ???? ???? ? ??? ??? ? ? ????.

create table if not exists demo.warehouse
(
    id bigint primary key generated always as identity,
    name varchar(255) not null
);

comment on table demo.warehouse is 'Information about the warehouses';
comment on column demo.warehouse.id is 'Unique identifier of the warehouse';
comment on column demo.warehouse.name is 'Human readable name of the warehouse';

??? ? ??? ???????? ?? ?? ???? ???? ????? ???? ?? ? ? ????. ?? ??? ?? ??? ?? ?? ??? ?? ???? ???(Buffers ????).

@Test
void checksShouldWork() {
    assertThat(checks)
        .hasSameSizeAs(Diagnostic.values());

    checks.stream()
        .filter(DatabaseCheckOnHost::isStatic)
        .filter(c -> c.getDiagnostic() != Diagnostic.TABLES_WITHOUT_DESCRIPTION &&
            c.getDiagnostic() != Diagnostic.COLUMNS_WITHOUT_DESCRIPTION)
        .forEach(c -> assertThat(c.check())
            .as(c.getDiagnostic().name())
            .isEmpty());
}
@Test
void checksShouldWork() {
    assertThat(checks)
        .hasSameSizeAs(Diagnostic.values());

    checks.stream()
        .filter(DatabaseCheckOnHost::isStatic)
        .forEach(c -> {
            final ListAssert<? extends DbObject> listAssert = assertThat(c.check())
                .as(c.getDiagnostic().name());
            switch (c.getDiagnostic()) {
                case TABLES_WITHOUT_DESCRIPTION, COLUMNS_WITHOUT_DESCRIPTION -> listAssert.hasSizeGreaterThanOrEqualTo(0); // ignored

                default -> listAssert.isEmpty();
            }
        });
}

?? ?? ?? ?? ?? ???? ???? ??? ?? ???? ?????.

@Test
void checksShouldWorkForAdditionalSchema() {
    final PgContext ctx = PgContext.of("additional_schema");
    checks.stream()
        .filter(DatabaseCheckOnHost::isStatic)
        .forEach(c -> {
            final ListAssert<? extends DbObject> listAssert = assertThat(c.check(ctx))
                .as(c.getDiagnostic().name());

            switch (c.getDiagnostic()) {
                case TABLES_WITHOUT_DESCRIPTION, TABLES_NOT_LINKED_TO_OTHERS ->
                    listAssert.hasSize(1)
                        .asInstanceOf(list(Table.class))
                        .containsExactly(
                            Table.of(ctx, "additional_table")
                        );

                default -> listAssert.isEmpty();
            }
        });
}

?? ???? ?? ??? ???? ?? ??? ?? ?? ?????.

create table if not exists demo.payment
(
    id bigint not null, -- column is not marked as primary key
    order_id bigint references demo.orders (id),
    status int not null,
    created_at timestamp not null,
    payment_total decimal(22, 2) not null
);

FOREIGN_KEYS_WITHOUT_INDEX ??? ???? ?? ?? ??? ??? ??? ???? ?? ??? ??? ? ????.

???? ???? ???, ??? ????

???? ??? ???? ?? ?????. ?? ?? ? ?? ???? ??? ????. ???? ???? ???? ??? ??? ??? ????. ?? ? ?? ?? ???, ?? ?? ?? ??? ?????. ??? ???? ??? 100% ???? ?? ??? ?? ??? ????? ?? ???. ???? ?? ?? ??? ???? ?? ????(??? ???? ??? ? ??).

?? ?? ???? ??? ??????? "????" ??? ?? ????, ??? ???? ??? ??????? "??" ??? ? ?? ????. . ??? ?? Percona ??? ???? ?? ? ???? ???? ?? ????? ? ??? ??? ???? ????. ??? DBA ?? ?????. ?? ?? DBA? ????

???? Null ?

????? PostgreSQL? btree ???? null ?? ????? ????? ???? ????. ?? null ?? ???? ? ?? null? ???? ??? ??? ?? ????. ???? ?? null? ????. ?? INDEXES_WITH_NULL_VALUES? ??? ??? ???? ? ??? ???.

orders ? order_items? ?? ?? ?????. order_item ????? ?? ID? ???? nullable ? warehouse_id? ????.

??? ?? ? ??? ??? ?????. ?? ??? ???? ??? ?????. ?? ??? ??? ?????? ?? ??? ???????.
-- well-formatted SQL
select
    pc.oid::regclass::text as table_name,
    pg_table_size(pc.oid) as table_size
from
    pg_catalog.pg_class pc
    inner join pg_catalog.pg_namespace nsp on nsp.oid = pc.relnamespace
where
    pc.relkind = 'r' and
    pc.oid not in (
        select c.conrelid as table_oid
        from pg_catalog.pg_constraint c
        where c.contype = 'p'
    ) and
    nsp.nspname = :schema_name_param::text
order by table_name;


??? ?? ??? ??, ??, ?? ??? ?? ???? ?? ????? ?? ?? ???? ??? ? ????. ??? ???? ??? ????? ?
-- poorly formatted SQL
SELECT pc.oid::regclass::text AS table_name, pg_table_size(pc.oid) AS table_size
FROM pg_catalog.pg_class  pc
JOIN pg_catalog.pg_namespace AS nsp
ON nsp.oid =  pc.relnamespace
WHERE pc.relkind = 'r’
and pc.oid NOT in (
  select c.conrelid as table_oid
  from pg_catalog.pg_constraint   c
  where    c.contype = 'p’
)
and nsp.nspname  = :schema_name_param::text
ORDER BY  table_name;

warehouse_id ??? ? ??? ?? ??(???? null?)
?? ??? ???? ???? ??? ????? ?? ?? ID? ???? ???. ?? ?? ??? ?? ??? ????.

dependencies {
    testImplementation("io.github.mfvanek:pg-index-health-test-starter:0.14.4")
}


? ?? ????

import io.github.mfvanek.pg.core.checks.common.DatabaseCheckOnHost;
import io.github.mfvanek.pg.core.checks.common.Diagnostic;
import io.github.mfvanek.pg.model.dbobject.DbObject;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class DatabaseStructureStaticAnalysisTest {

    @Autowired
    private List<DatabaseCheckOnHost<? extends DbObject>> checks;

    @Test
    void checksShouldWork() {
        assertThat(checks)
            .hasSameSizeAs(Diagnostic.values());

        checks.stream()
            .filter(DatabaseCheckOnHost::isStatic)
            .forEach(c -> assertThat(c.check())
                .as(c.getDiagnostic().name())
                .isEmpty());
    }
}
warehouse_id

?? ?? ???? ???? ????.

-- well-formatted SQL
select
    pc.oid::regclass::text as table_name,
    pg_table_size(pc.oid) as table_size
from
    pg_catalog.pg_class pc
    inner join pg_catalog.pg_namespace nsp on nsp.oid = pc.relnamespace
where
    pc.relkind = 'r' and
    pc.oid not in (
        select c.conrelid as table_oid
        from pg_catalog.pg_constraint c
        where c.contype = 'p'
    ) and
    nsp.nspname = :schema_name_param::text
order by table_name;

??? ??? ???? ?? ??? ??? ??? ? ???? ?????. ? ???? ???? Warehouse_id? null? ???? ???? ????? ??? ?? ???? ?? ?? ??? ????? ?? ? ?? ??? ?? ? ????.

-- poorly formatted SQL
SELECT pc.oid::regclass::text AS table_name, pg_table_size(pc.oid) AS table_size
FROM pg_catalog.pg_class  pc
JOIN pg_catalog.pg_namespace AS nsp
ON nsp.oid =  pc.relnamespace
WHERE pc.relkind = 'r’
and pc.oid NOT in (
  select c.conrelid as table_oid
  from pg_catalog.pg_constraint   c
  where    c.contype = 'p’
)
and nsp.nspname  = :schema_name_param::text
ORDER BY  table_name;

??? ?? ?? ??? ?? ??? ?? ???? ???? ???? ???? ????.

dependencies {
    testImplementation("io.github.mfvanek:pg-index-health-test-starter:0.14.4")
}

?? ?? ??? ??????? ???? ??? ??? ??? ????. warehouse_id ?? ?????? ????. ?, ?? ??? ?? ?? ?? ????. ? ?? ???? ???? ????. ??? ???? ???? ? ? ?? ?? ?? ??? ?(?: ?????) ?? ??? ?????. ?? ?? ?? ???? ???? 1???.

warehouse_id ??? null ?? ???? ?? ???? ???? ???? ???? ?? ? ????.

import io.github.mfvanek.pg.core.checks.common.DatabaseCheckOnHost;
import io.github.mfvanek.pg.core.checks.common.Diagnostic;
import io.github.mfvanek.pg.model.dbobject.DbObject;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class DatabaseStructureStaticAnalysisTest {

    @Autowired
    private List<DatabaseCheckOnHost<? extends DbObject>> checks;

    @Test
    void checksShouldWork() {
        assertThat(checks)
            .hasSameSizeAs(Diagnostic.values());

        checks.stream()
            .filter(DatabaseCheckOnHost::isStatic)
            .forEach(c -> assertThat(c.check())
                .as(c.getDiagnostic().name())
                .isEmpty());
    }
}

?? ???? ? ???? ?? ? ? ????.

create table if not exists demo.warehouse
(
    id bigint primary key generated always as identity,
    name varchar(255) not null
);

comment on table demo.warehouse is 'Information about the warehouses';
comment on column demo.warehouse.id is 'Unique identifier of the warehouse';
comment on column demo.warehouse.name is 'Human readable name of the warehouse';

???? ??? ??? ?? ??? ??? ? ? ????. ?? ??? ?? ? ??? ???? ??? ????. ? ???? ???? ??? ??? ???? ??? ?????.

??? ??? ???? ??
@Test
void checksShouldWork() {
    assertThat(checks)
        .hasSameSizeAs(Diagnostic.values());

    checks.stream()
        .filter(DatabaseCheckOnHost::isStatic)
        .filter(c -> c.getDiagnostic() != Diagnostic.TABLES_WITHOUT_DESCRIPTION &&
            c.getDiagnostic() != Diagnostic.COLUMNS_WITHOUT_DESCRIPTION)
        .forEach(c -> assertThat(c.check())
            .as(c.getDiagnostic().name())
            .isEmpty());
}

table_name index_name index_size_bytes
demo.order_item demo.idx_order_item_warehouse_id 1056768
demo.order_item demo.idx_order_item_warehouse_id_without_nulls 16384

??? ?? ??

??? ??? pg-index-health? ??? ? ?? ?? ???? ??? ????. ?? ?? ??? GitHub ????? README?? ??? ? ??? ????? ?????.

pg-index-health? Spring Boot ??????? ???? ?? ?? ?????. ??? ???? ? ?? ????? ??????. ????? ???? ?? ? ????? ???? ? ????. ? ??? ??? ????!

??? ?? ??? ??? ???? ?? ??? ??? ??? ?????. ?? ?? 25? ?? ? 11?? ???? ?????. ?? ?? ?? ??? ????. ?? 5? ??? ??? ??? ???? ?? ??? ????. ????? 2025??? Java 17? Spring Boot 3?? ??? ?????.

??? ??

  • pg-??-??
  • ??? ?? ?? SQL ??
  • ?? ??????

?? ??

  • ????? ? ? ?? ???
  • ??? ??? - SchemaCrawler
  • DBA: ???? ??? ??(????)
  • Java ???? ??? ? PostgreSQL? ??? ??(????)
  • ?????? ??? ?? ??(????)

? ??? pg-index-health – PostgreSQL ??????? ?? ?? ?? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

?? ????
1783
16
Cakephp ????
1725
56
??? ????
1577
28
PHP ????
1441
31
???
?? ?? ?? ??? ??? ?? ?? ?? ??? ??? Jun 24, 2025 pm 09:41 PM

?? ?? ?? ??? ??? ?? ??? ??, ? ? ?? ? ??? ?????. 1. ??? ?? ???? ?? ???? ???-????, ? ??? ??? ??? ? ????, Hashmap? ???-??? ?? ??? ??? ???? ????. 2. NULL ? ?? ???? HashMap? ??? NULL ?? ?? ? ?? ???? ?? HashTable? NULL ?? ?? ???? ??? NullPointerException? ?????. 3. ????? ??? ????? ?? ??? ?? ?? ? ????? HashTable? ? ??? ?? ?? ??? ????. ?? ConcurrenTashMap? ???? ?? ????.

?? ???? ??? ??? ?????? ?? ???? ??? ??? ?????? Jun 28, 2025 am 01:01 AM

Java? ?? ??? ??? ?? ??? ??? ?? ??? ??? ?? ??? ?? ?? ??? ???? ??? ?? ???? ?????. 1. ??? ???? ??? ?? ?? ? ???? ?? ??? ???? ?? ?? ??? ? ????. 2. ???? ?? ??? ???? ??? ?? ???? ?? ?? ??? ???????. 3. ?? ???? ?? ?? ?? ? ???? ???? ?? NULL ?? ??? ? ????. 4. ?? ???? ??? ?? ?? ? ??? ?????? ?? ??? ??? ?? ?? ??? ????? ??? ??? ??? ??????? ?? ???? ??????.

?????? ?? ???? ?????? ?????? ?? ???? ?????? Jun 24, 2025 pm 10:57 PM

staticmethodsininterfaceswereIntRectionSelffacesswithinteffaceswithinteffaceswithintintinjava8toallowutilityFunctionswithinterfaceitswithinteffaceswithinterfaceffaces

JIT ????? ??? ??? ??????? JIT ????? ??? ??? ??????? Jun 24, 2025 pm 10:45 PM

JIT ????? ??? ???, ??? ?? ? ???, ?? ?? ? ???? ? ? ?? ?? ??? ? ?? ??? ?? ??? ??????. 1. ??? ???? ?? ?? ??? ??? ?? ?? ???? ??? ?? ?????. 2. ??? ?? ? ??? ?? ?? ? ??? ???? ?? ?? ???; 3. ?? ??? ??? ?? ??? ???? ???? ???? ? ?? ?? ??? ?????. 4. ?? ??? ?? ??? ??? ???? ???? ?? ? ??? ???? ?? ??? ?????.

???? ??? ??? ??? ?????? ???? ??? ??? ??? ?????? Jun 25, 2025 pm 12:21 PM

???? ??? ??? Java?? ??? ?? ???? ??? ?? ? ? ??? ??? ???? ? ?????. ?? ???? ??? ??, ??? ?? ??? ?? ?? ??? ??? ????? ???? ????? ?????. ?? ??? ??? ??, ????? ? ??? ????, ?? ??? ??? ?????? ? ?? ? ?? ?????.

?? ??? ?????? ?? ??? ?????? Jun 24, 2025 pm 11:29 PM

??? ??? ?? ?? ??? ????? ? ???? ????? ???? ?? ???? ?? ???? ?????. ?? ??? ??? ????. ?? ?? ?? ??? ???? ???? ?? ?? ??? ??? ?? ?? ??? ??? ?????. ?? ??? ??? ????. ?? ??? ?? ??? ?? ?? ??? ?? ?? ??? ???? NewClass ()? ??? ?? ???? ????. ?? ??? ?? ??? ???? ?? ??? ?? ? ? ??? ?? ?? ??? ????? ????? ?????. ?? ??, ?? ?????? ?????, ??? ? ?? ????? ??? ?? ?????. ???? ?? ?? ??? ???? ?? ???? ?? ? ??? ???? ?? ??? ?? ?????? ?????. ???? ???? ??? ??, ?? ?? ? ?? ??? ????, ?? ?? ???? ?????.

??? '??'???? ?????? ??? '??'???? ?????? Jun 24, 2025 pm 07:29 PM

injava, thefinalkeywordpreventsavariable'svalue'svalueffrombeingchangedafterassignment, butitsbehaviordiffersforprimitivesandobjectreences.forprimitivevariables, asinfinalintmax_speed = 100; wherereassoncesanerror.forobjectref

?? ????? ?????? ?? ????? ?????? Jun 24, 2025 pm 11:09 PM

??? ? ?? ??? ???? : ????? ?? ?. 1. int? ???? ???? ?? ?? ?? ? ??? ???? ?????. 2. ?? ? ???? (int) myDouble ??? ?? ?? ??? ?????. ?? ??? ??? ?? ??? ?? ??, ?? ?? ?? ???? ?? ??? ?? ???? ?? ?????. ???? ? ??? ??? ????. ?? ??? ??? ??? ??? ??? ?? ??? ??? ? ??? ?? ???? ??? ??? ??? ??? ? ??? ?? ??? ?? ??? ?? ?? ? ? ????. ?? ?? ??? ?? ??? ??? ??? ??? ? ??????.

See all articles