Coder Social home page Coder Social logo

Comments (10)

edbond avatar edbond commented on August 20, 2024 4

Had to do:

DROP FUNCTION pg_stat_statements_reset();
DROP FUNCTION pg_stat_statements() CASCADE;
       NOTICE:  drop cascades to view pg_stat_statements
CREATE EXTENSION pg_stat_statements;

pghero is happy.

from pghero.

StalkAlex avatar StalkAlex commented on August 20, 2024 2

CREATE EXTENSION pg_stat_statements shows me ERROR: permission denied to create "pg_catalog.pg_stat_statements". Current user is superuser. what should I do?

from pghero.

edbond avatar edbond commented on August 20, 2024

seems to be not installed?

<db>=# SELECT * FROM pg_available_extensions WHERE name = 'pg_stat_statements';
        name        | default_version | installed_version |                          comment                     

--------------------+-----------------+-------------------+------------------------------------------------------
-----
 pg_stat_statements | 1.1             |                   | track execution statistics of all SQL statements exec
uted
(1 row)

but I use that to email slow queries daily.

    results = PgStatStatement.select("*, round((total_time / calls)::numeric, 2) as s").
      order("s DESC").all

from pghero.

ankane avatar ankane commented on August 20, 2024

Very odd. Does pg_stat_statements appear in this query with installed true?

SELECT * FROM pg_available_extension_versions;

Do you recall how pg_stat_statements was originally installed?

from pghero.

edbond avatar edbond commented on August 20, 2024

No, it's not installed.

        name        | version | installed | superuser | relocatable | schema | requires |                        
  comment                          
--------------------+---------+-----------+-----------+-------------+--------+----------+------------------------
-----------------------------------
 pg_stat_statements | 1.1     | f         | t         | t           |        |          | track execution statist
ics of all SQL statements executed
(1 row)

I didn't run create extension, just add to shared_libraries following instructions:
http://www.postgresql.org/docs/9.2/static/pgstatstatements.html

The module must be loaded by adding pg_stat_statements to shared_preload_libraries in postgresql.conf, because it requires additional shared memory. This means that a server restart is needed to add or remove the module.

from pghero.

edbond avatar edbond commented on August 20, 2024

it seems something wrong with db. Tried with new db on my local (postgresql 9.3.5)

→  createdb zxc
→  psql zxc
zxc=# SELECT * FROM pg_stat_statements;
ERROR:  relation "pg_stat_statements" does not exist
zxc=# CREATE extension pg_stat_statements;
CREATE EXTENSION
zxc=# SELECT * FROM pg_stat_statements;
 userid |  dbid  |                                                                                               ........

from pghero.

ankane avatar ankane commented on August 20, 2024

You'd lose historic data, but one option is to drop functions and views as you hit errors with CREATE EXTENSION pg_stat_statements.

DROP FUNCTION pg_stat_statements_reset;
-- DROP VIEW pg_stat_statements; etc

from pghero.

edbond avatar edbond commented on August 20, 2024

It seems a weird bug with particular DB. Will do cleanup as you advised. Thx

from pghero.

ankane avatar ankane commented on August 20, 2024

Thanks for following up with your solution! I'm sure others encountering this will find it useful.

from pghero.

jbejar avatar jbejar commented on August 20, 2024

https://github.com/ankane/pghero/blob/master/guides/Query-Stats.md

from pghero.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.