ankane / dexter

The automatic indexer for Postgres
MIT License
1.9k stars 47 forks source link

Dexter don't detect anything #29

Closed debnet closed 5 years ago

debnet commented 5 years ago

Running dexter over my database (PostgreSQL 11.2) doesn't seems to detect anything, passing by the logs or by pg_stat_activity. No errors though, just wont detect anything at all...

(motherbase) [marc@marcbook backend]$ dexter -U postgres -d motherbase --pg-stat-activity --log-level debug2 --analyze
Started
Processing 0 new query fingerprints
Processing 0 new query fingerprints
Processing 0 new query fingerprints
Processing 0 new query fingerprints
Processing 0 new query fingerprints

whereas my logs looks like the following:

2019-04-10 15:42:10.571 CEST [32086] LOG:  durée : 27696.749 ms, instruction : SELECT DISTINCT "generic_company"."id"
    FROM "generic_startup" 
    LEFT OUTER JOIN "cse_cse" ON ("generic_startup"."company_ptr_id" = "cse_cse"."startup_id") 
    INNER JOIN "cse_cse" T4 ON ("generic_startup"."company_ptr_id" = T4."startup_id") 
    INNER JOIN "generic_company" ON ("generic_startup"."company_ptr_id" = "generic_company"."id") 
    INNER JOIN "generic_startup_entities" ON ("generic_startup"."company_ptr_id" = "generic_startup_entities"."startup_id") 
    WHERE (
        T4."corporate_id" IN (
            -- SELECT U0."company_ptr_id" FROM "generic_corporate" U0 WHERE U0."company_ptr_id" IN (
                20112, 20120, 20113, 20117, 20119, 20121, 20115, 20111, 20118, 20116, 20114
            -- )
        ) 
        AND NOT (
            "generic_startup"."company_ptr_id" IN (
                SELECT U1."startup_id" FROM "cse_cse" U1 WHERE U1."valid" = false
            )
        ) 
        AND "generic_startup_entities"."entity_id" IN (
            SELECT U0."id" FROM "generic_entity" U0 WHERE U0."id" IN (3)
        )
    ) 
    GROUP BY "generic_company"."id", "generic_startup"."company_ptr_id" 
ankane commented 5 years ago

Hey @debnet, the regex used for log parsing only checks for English messages (it expects lc_messages to be en_US.UTF-8).

https://github.com/ankane/dexter/blob/cfd3af85eff3cd48801b87f4c4df8cc104aaaf7d/lib/dexter/log_parser.rb#L5

You can try piping the file through sed to get it to match the expected format.

LOG:  duration: 2051.529 ms  statement: SELECT 123...
debnet commented 5 years ago

Oh, OK. Good to know, an addition of that point into the documentation could be handy for the others. ;)