pawurb / ruby-pg-extras Goto Github PK
View Code? Open in Web Editor NEWRuby PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more.
License: MIT License
Ruby PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more.
License: MIT License
Hi, I'm not sure if this is the right place to file this (I'm actually using rails-pg-extras
, however I think the exception I'm seeing is coming from this gem.
When loading the landing page for rails-pg-extras
(diagnostics) it throws the following error:
An ActionView::Template::Error occurred in queries#index:
undefined method `fetch' for nil:NilClass
end.fetch("installed_version", false)
^^^^^^
I can confirm that the server does not have sslinfo
installed and thus my theory is that this is tied to this:
If I navigate directly to the following url /pg_extras/queries?query_name=ssl_used
I receive this error message:
PG::UndefinedFunction: ERROR: function ssl_is_used() does not exist LINE 3: SELECT ssl_is_used(); ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
I'm having a hard time replicating it locally. Not sure if it makes sense that sslinfo
really isn't installed?
The gem has a dependency on the now unsupported filesize
gem - https://github.com/dominikh/filesize
The dependency is extremely minor. It consists of two references
1 MB
to a constant int value, which can just be replaced by the constant int valueunused_indexes
caseGiven that the dependency is now unsupported, it should probably be removed. I'm happy to put together a PR if there is interest in resolving the issue.
Sorry that I'm creating another issue.
I'd like to use auto_explain feature on our production instance. But it doesn't seem that this gem comes with any support for it.
Maybe I'm missing something? Would you be keen to add support for that as well?
Thanks for a great gem
Thanks for this awesome gem - I made a quick monkey patch to puts to return strings so that the output can be caputered/displayed differently. I think this is valid usecase to implement properly in the gem.
RubyPGExtras.puts_returns_string = true
# now all table prints return uncolorized strings
module RubyPGExtras
@@puts_returns_string = false
def self.puts_returns_string
@@puts_returns_string
end
def self.puts_returns_string=(value)
@@puts_returns_string = value
end
end
class String
REGEXP_PATTERN = /\033\[([0-9]+);([0-9]+);([0-9]+)m(.+?)\033\[0m|([^\033]+)/m
def uncolorize
self.scan(REGEXP_PATTERN).inject("") do |str, match|
str << (match[3] || match[4])
end
end
end
module RubyPGExtras
def self.puts(args)
if @@puts_returns_string
args.to_s.uncolorize
else
Kernel.puts args
end
end
end
module RubyPGExtras
class DiagnosePrint
def puts(args)
RubyPGExtras.puts args
end
end
end
module RubyPGExtras
class TableInfoPrint
def puts(args)
RubyPGExtras.puts args
end
end
end
module RubyPGExtras
class IndexInfoPrint
def puts(args)
RubyPGExtras.puts args
end
end
end
Didn't really have a better title for this but...
I've started building out a feature in our application that uses multiple schemas. This means, that when I later use rails-pg-extras
and RailsPGExtras.index_usage
I get indexes for materialized views I've created in this other schema. Since the views I'm creating have the same name as tables in the public schema, I'll get duplicate entries for users
, for example. The output doesn't include the schema name so I don't get that information and can't pick the correct version of the index I care about.
Basically, the end goal is I want to include only the public schema for index_usage
, and basically anything else that would include things in multiple schemas. So either I need to be able to customize the query, or get more information from the query so I can ignore it later on, or something else. I'm open to suggestions. I could fork the gem, but this seems like something that could be useful for other people.
Ideas? I can make a PR if there's some direction you think would be best.
pg_buffercache
is one of those built-in extensions that provides lots of good feedback. It provides a means for examining what's happening in the shared buffer cache in real time. I'm working on a few Rails tasks and I thought it would be a great idea to provide them here instead. Would you merge it if I come up with a pull request?
This is kind of evolving an idea used in null_indexes
. Additionally to suggesting partial indexes when we have a lot of NULL
s in the column, we can suggest partial indexes for columns where we have a high % of the same value.
For example, for the table with millions of users an index on role
was added (to quickly find admins, for example). But 99% of the users are regular users, several are admins, moderators, etc. So the partial index where role != 'regular'
would be beneficial.
I was wondering, if there are any plans or ideas to use pg_stat_monitor extension in this gem? Just from my rough research, it seems that a lot of data point seems similar, but there are quite a lot of useful datapoints on top.
More info could be found here:
https://www.percona.com/blog/understand-your-postgresql-workloads-better-with-pg_stat_monitor/
This is a really helpful gem! I'm the author of GoodJob, which uses a lot of Advisory Locks. This gem (and rails-pg-extras
) came up in an issue (bensheldon/good_job#480).
For Advisory Locks in all_locks
, the age
isn't accurate because the query is fetching the time of the connection's last query, not necessarily the age of the Advisory Lock itself:
I wanted to suggest renaming it, maybe last_activity_age
(naming is hard).
And, I also wanted to suggest including pg_stat_activity.application_name
in the output. I think that application_name
can provide high-context information that would be really useful for understanding what's happening with the locks.
Hi there!
I'm not a lawyer but colorize
is under GPL 2.0 and it reminds me this : https://dev.to/cseeman/what-s-up-with-mimemagic-breaking-everything-he1
As alternative to colorize
there is paint which is under MIT license and rainbow.
There's also an issue on colorize
repo : fazibear/colorize#47
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.