Skip to content

Fetch most recent value – sql execution time too long

I have a Firebird database with a table with two columns: Date and value. I want to get the most recent value. Problem is, that this table can have easily over 200k rows. My select query takes more than 400ms, which is just to long for my application. Is there any way, I can speed this up? I can’t chang…

SQL Update One Table If Record Does Not Exist In Another Table

The above works to give me all the customer accounts that have no invoices. It takes a long time to run, but I’m not concerned with the speed. I will likely only run this a couple times a year. What I can’t get right is updating a record in the customers table when the account has no invoices. I h…

How to populate dictionary using SQL table data

In my C# project, I have a dictionary, its values are currently static. Now I need to set to its values in dynamically. how can I do that? I have an Oracle DB table called “country” there have two columns called, ID and CountryName as follows, How can I set this table values to my dictionary? Than…

Do a dry-run of an Alembic upgrade

Sometimes alembic upgrade head may fail at runtime against my production database even though it worked fine against my testing databases. For instance, a migration might add a NOT NULL constraint to a column that didn’t previously contain NULLs in my testing environment, but did contain NULLs in produc…

Extract string between double quotes in SQL

I have a string and I need to return the characters between the double quotes ‘((“Name 1” and “Name 2”) or “Name 3”) I need to return I have used the function below to split the string but I am getting the (( and the Or and AND etc .. which I don’t want and unfo…

Golang db query using slice IN clause

Can someone explain to me why this does not work? And this does I’m trying to do a simple IN clause with a slice of ints, and every solution suggested doesn’t seem very idiomatic Tried to do this, but the problem appears to be the string substitution. I’m a bit surprised that go doesn’…