11
votes
Accepted
Multithreaded UDP server that advertises itself in a PostgreSQL database and launches other servers in response to messages from a client
Pre-review notes
Before we dive into the review, I have some notes. Some of these are replies to questions or concerns raised, and others are my own questions or concerns that come out of the code ...
7
votes
Accepted
Cryptocurrency notifier - let's get rich (or at least let's try)
I know I don't have docstrings and that my API keys shouldn't be
stored in my program (the same for DB credentials), so try to avoid
these aspects when reviewing my code.
Just mentioning even ...
7
votes
Accepted
A schema for awallet system that allows transfers between users
redundant wallets
CREATE TABLE wallets (
id UUID PRIMARY KEY ...,
user_id UUID REFERENCES users(id), ...
currency VARCHAR(3) ...
This isn't ...
6
votes
A schema for awallet system that allows transfers between users
Time zone
Instead of using naive datetimes, I would strongly recommend time zone-aware types eg TIMESTAMP WITH TIME ZONE. See relevant doc for available options. A ...
5
votes
Correct using of try/catch clause on database execution
Just one short note...
catch (NullReferenceException e)
You never want to catch this exception explicitly. 99.999% of the time its occurance means there is a ...
5
votes
Accepted
Correct using of try/catch clause on database execution
Some quick remarks:
Avoid writing ADO.NET code by hand; instead use an ORM like Dapper.
Why not use MAX() -- which I think is supported by PostgreSQL -- instead of <...
5
votes
Postgres query to extract a JSON sub-object from a JSON field
I'd recommend (if it isn't already) converting to the type from json to jsonb and adding a GIN index. The documentation below lays it out pretty clear. Good luck!
https://www.postgresql.org/docs/9.4/...
5
votes
Multithreaded UDP server that advertises itself in a PostgreSQL database and launches other servers in response to messages from a client
Simpler value-initialization:
UUID() : uuid(std::array<const uint8_t, 16>{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}) {}
Can just be:
...
4
votes
Accepted
Update SQL database, similar-but-different queries for each month
There are two main problems with this:
Firstly, as you've identified, your approach will involve a lot of repeated code. The only thing that changes for each of your SQL commands is the monthid field ...
4
votes
Iterate between dates and INSERT values in a performant way
Instead of a loop which inserts one row after the other you should use generate_series to create all timestamps at once.
Untested:
...
4
votes
Accepted
Historical Funding Rate Miner for ftx.com
Code should be correct, maintainable, robust, reasonably efficient, and, most importantly, readable. Code should be useful and have real value.
I found your code hard to read. Your code does not ...
4
votes
Accepted
Postgres DB design
What probably stands out most is the foreign key in sh_staff_members which also functions as a PK. While inheritance seems like a better tool to represent the is-a relationship between sh_staff_member ...
3
votes
Accepted
Discord.py Pokemon Bot performance problems
Almost certainly the largest slow-down is that you are getting each individual value on its own. Instead get all information at once:
...
3
votes
3
votes
Accepted
Python script to find employees who are in one PostgreSQL table but not in another
LEFT JOIN from test_test to test_table selecting only rows where test_table.test_emp_id is <...
3
votes
Accepted
Enforcing a constraint that a user may vote on each post at most once
which one is more efficient
Almost surely the unique index will be. Querying back and forth between the server and database is very expensive, and the query that you would have to write to check the ...
3
votes
Accepted
OOP Python Blackjack game with player accounts in PostgreSQL
Here are a few things that caught my eye while quickly looking through your code:
Imports
As per the official Style Guide for Python Code (aka PEP8), imports ...
3
votes
Consume etherscan.io API, store in DB, serve from web app
I must say it a very interesting assignment to do:
what I see missing from your assignment is not much bigger things in development aspects but it all have a huge impact on Code maintainability and ...
3
votes
Update SQL database, similar-but-different queries for each month
What is con? con is a reference to my database connection which is public.
I have to disappoint you beceause it is not public. Class members are ...
3
votes
Accepted
Postgres Shopping Database using Python
Before anything, read on SQL parameterization and avoid concatenating or interpolating variables directly in SQL statements. Otherwise you open your application to SQL injection and inefficiencies. ...
3
votes
Fetching all nodes of a directed graph by an id of any node
I am not well qualified to answer this, as I know nothing of PostgreSQL or the RECURSIVE extension you are using, so unfortunately I cannot very well comment on your solution.
However perhaps it can ...
3
votes
Selecting changes from a temporal table
Externalize your DML
Given the length of the query written in GetArticleChangesAsync, I would expect that either
it be moved to a stored procedure (common but IMO ...
3
votes
Accepted
Creating SQL Table from a Go Struct
None of your columns are marked non-nullable. This is important for data integrity.
duration and date both seem mis-represented ...
3
votes
Accepted
PostgreSQL: Grouping and Aggregating on multiple columns
Each row in ipl_m table has one winner and one loser.
So first extract winners and set field result (it will be used in counting)...
3
votes
Update table with data from another table under certain criteria
Too many unnecessary joins and subqueries.
Clean solution:
...
3
votes
Accepted
Find and conditionally sort all venues matching a filter provided by an API client in PostgreSQL
distance
Here's a curious column:
...
3
votes
Serialized document inventory management splicing/slicing function
complex DELETE
I confess I don't quite understand the motivation
behind that SQL statement.
It seems to be about finding set difference of kept_ranges
and then un-nesting?
I predict that when you ...
2
votes
C# SQL query builder to fill DataTable
The code that queries the database and returns sick days, holidays, working days, has a pattern to it. The code sets parameters, runs scalar/datatable query, sets parameters... and so forth.
I'm ...
2
votes
C# SQL query builder to fill DataTable
I can't really help with the performance issue because following your code is really hard (I don't speak the language it's in). That said, I just can't look at this and say nothing:
...
2
votes
Correct using of try/catch clause on database execution
Is it okay to have the try/catch block outside the using statement block?
I see no apparent reason why having a try/catch outside of a ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
postgresql × 175sql × 91
python × 41
performance × 29
python-3.x × 19
database × 16
ruby × 12
ruby-on-rails × 11
c# × 8
php × 8
beginner × 7
json × 6
go × 6
django × 6
stored-procedure × 6
plpgsql × 6
javascript × 5
mysql × 5
datetime × 5
node.js × 5
c++ × 4
object-oriented × 4
active-record × 4
java × 3
game × 3