All Questions
17 questions
0
votes
1
answer
45
views
Find and conditionally sort all venues matching a filter provided by an API client in PostgreSQL
I have an API where users can retrieve a list of "venues".
Every venue is a profile, but not every profile is a venue
Venues can be "parents" of other venues (think hotel - floor -...
3
votes
1
answer
55
views
Enforcing a constraint that a user may vote on each post at most once
I have the following table in a PostgreSQL database:
...
3
votes
1
answer
55
views
Iterate between dates and INSERT values in a performant way
I have created a query that populates a datapoint with random values.
The logic is simple: Iterate between the START and END dates and INSERT random values.
I want from this query to be very ...
2
votes
4
answers
2k
views
C# SQL query builder to fill DataTable
I'm trying to optimize my code and in the process of doing that I made a class Query_builder that handles SQL queries. That class has couple of methods: ...
0
votes
1
answer
52
views
Count buffered streets that intersect buffered points using PostGIS
PostgreSQL 9.5.1 with PostGIS 2.0 extension
This first section creates an intersection (clip) of the streets from another polygon (MTC15), then it buffers the intersection:
...
2
votes
1
answer
797
views
Parsing data from big json field and geocode services then store to PostgreSQL using psycopg2 instead django-orm
This code works, but my boss told me that it's very bad code, and don't want to deploy it. It is my first time working as a programmer and I have at least 3 months of experience.
...
8
votes
1
answer
80
views
Searching text, starring, flagging and joins
I have an interesting performance concern that I would like to address before it becomes a serious issue. I created a SQL Fiddle to demonstrate the query, and the explain statement can be seen on ...
1
vote
1
answer
77
views
Bookmaker odds and offers query
The following query returns the latest Odds for each Offer based on the timestamp on the Odds...
15
votes
1
answer
302
views
Complicated article sort
In short I have a bunch of articles (~100k) which shall be ranked ("mixed", hence "newsmix") based on their newsValue (how important they are, between 1 and 10) and newsLifetime (...
6
votes
2
answers
222
views
What are the latest Odds?
The main problem the following query is solving, is the following:
Each Offer has multiple Odds (...
8
votes
2
answers
134
views
Benchmarking of SQL data crunching using a common datum
@nhgrif and I were curious about a couple different ways to aggregate a number of records based on a duplicate/common datum. Two different ideas will be shown. Any advice on all code but especially ...
3
votes
1
answer
2k
views
Taking data from staging table and inserting into target tables
I have the below mentioned function written in plpgsql which is working fine. I want someone to review it and let me know how can I improve its performance.
This function takes data from staging ...
15
votes
4
answers
2k
views
Finding person with most medals in Olympics database
I have an Olympics database from each Olympic year and I want to find the person that has won the most medals. The main problem is that I'm basically querying the same sub-query twice in ...
2
votes
2
answers
103
views
Query of users for some age, gender, and state, using a subselect
I have this query:
...
6
votes
1
answer
1k
views
Help optimizing this query with multiple where exists
In the application I'm building, the user is able to define 'types' where each 'type' has a set of 'attributes'.
The user is able to create instances of products by defining a value for each ...