Skip to main content
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 ...
indi's user avatar
  • 16.5k
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 ...
hjpotter92's user avatar
  • 8,921
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 ...
J_H's user avatar
  • 42.3k
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 ...
Kate's user avatar
  • 8,313
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 ...
t3chb0t's user avatar
  • 44.7k
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 <...
BCdotWEB's user avatar
  • 11.4k
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/...
Robert Smith's user avatar
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: ...
user673679's user avatar
  • 12.2k
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 ...
Steven Eccles's user avatar
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: ...
dnoeth's user avatar
  • 1,222
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 ...
peterSO's user avatar
  • 3,591
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 ...
Reinderien's user avatar
  • 71.1k
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: ...
Graipher's user avatar
  • 41.7k
3 votes

SQL Bulk status update

Query formatting ...
JAD's user avatar
  • 2,959
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 <...
Jono Brogan's user avatar
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 ...
Reinderien's user avatar
  • 71.1k
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 ...
AlexV's user avatar
  • 7,363
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 ...
Shishir Sonekar's user avatar
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 ...
t3chb0t's user avatar
  • 44.7k
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. ...
Parfait's user avatar
  • 980
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 ...
George Barwood's user avatar
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 ...
Reinderien's user avatar
  • 71.1k
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 ...
Reinderien's user avatar
  • 71.1k
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)...
JulStrat's user avatar
  • 350
3 votes

Update table with data from another table under certain criteria

Too many unnecessary joins and subqueries. Clean solution: ...
Basil Peace's user avatar
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: ...
J_H's user avatar
  • 42.3k
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 ...
J_H's user avatar
  • 42.3k
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 ...
null's user avatar
  • 231
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: ...
RobH's user avatar
  • 17.1k
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 ...
Nkosi's user avatar
  • 3,296

Only top scored, non community-wiki answers of a minimum length are eligible