Skip to content
Advertisement

Tag: postgresql

Statistics on Query Time (PostgreSQL)

I have a table with a billion rows and I would like to determine the average time and standard deviation of time for several queries of the form: I have a thousand random values for col1 stored in another table. Is there some way to store how long each of these queries took (in milliseconds) in a separate table, so

Similarity function in Postgres with pg_trgm

I’m trying to use the similarity function in Postgres to do some fuzzy text matching, however whenever I try to use it I get the error: If I add explicit casts to text I get the error: My query is: Do I need to do something to initalize pg_trgm? Answer You have to install pg_trgm. In debian, source this sql:

List columns with indexes in PostgreSQL

I would like to get the columns that an index is on in PostgreSQL. In MySQL you can use SHOW INDEXES FOR table and look at the Column_name column. Does anything like this exist for PostgreSQL? I’ve tried d at the psql command prompt (with the -E option to show SQL) but it doesn’t show the information I’m looking for.

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter “A”: That’s fine for letters, but how do I list all items starting with any number? For what it’s worth this is on a Postgres

How To Do Percent/Total in SQL?

I have an typical CUSTOMER/ORDERS set of tables and I want to display the total percentage of sales a particular customer is responsible for. I can get the total number of orders in the system like so: And I can get the the total number of orders made by the customer like so: How can I combine these into a

Advertisement