New answers tagged

0

As already suggested, use DBCC CHECKDB (or perhaps CHECKTABLE for a more directed check, but when corruption s suspected I'd err in the direction of checking everything and it sounds like this table is the majority of your DB anyway). If you can restore a backup from before you started the process and check that too, preferably on a different machine, you'll ...


0

Did you really mean varbinary(max)? Seems strange to have non-text data in a text-type column. Anyhow, corruptions shouldn't occur. Your first step would be to make sure that you are up to date within the version of SQL Server you are using. I.e., (service pack and) CU. If it persists, then I'd suspect a bug in SQL Server or that a corruption already existed ...


0

I've been using flyway a lot and it's perfect for PostgreSQL. Flyway integrates well with git, CI-CD flows and containers, and is easy to set up. You will less enjoy using flyway together with MySQL or Oracle DB, because they do not support transactional DDLs. But that's not flyway's fault. Flyway's enterprise version supports migration rollback. I haven't ...


2

The additional CPUs can only be used if you use more sessions/connections. If you increase the number of sessions, then a higher number of CPUs should show an increase in throughput. However, the throughput is not only limited by CPU, but also by the capacity of your I/O system. If the current workload is I/O bound (i.e. limited by the performance of the ...


1

You can use a data modifying CTE to do this in a single statement: with changed_user as ( UPDATE users SET free_shipping_until = spu.created_at::date + interval '1 year' FROM shipping_priority_users AS spu WHERE spu.role_id = #{role.id} and users.id = spu.user_id and spu.created_at is not null returning * ) insert into log (user_id, ...


2

The usual way is to import the CSV file into a staging table. Either an unlogged table which you only create once, or a temp table which you create immediately before the import. Something along the lines: create temp table inventory_import (item_id integer primary key, quantity integer); copy inventory_import from '/path/to/file.csv' ... ; update ...


0

As you don't tell us ´,w hat for an Update you will have, I selected one . where the lst of a type get 5 Minutes more on his End time, this is of corse only an example for an update, to show how it works. The latest seen time we get from the WINDOW Function MAX OVER PArtition And the update only update the types with the latest time (i choose ...


1

From the documentation: The update and delete operators in a parallel query execution plan are executed serially, but the WHERE clause of an UPDATE or a DELETE statement may be executed in parallel. The actual data changes are then serially applied to the database. As to your second question, does it guarantee a communication buffer resource deadlock Any ...


0

Maybe: UPDATE A SET A.active = 1 WHERE A.date >= '2020-01-01' AND ( EXISTS ( SELECT 1 FROM B WHERE B.id = A.id ) ) What is the datatype of date? If it is DATE, you were excluding New Year's Day. I'm assuming that id is the PRIMARY KEY if each table. But, given that, I must ask why you have two tables with the same PK -- That is usually ...


1

I would recommend using this trigger template where possible. change it to suit your needs, of course. It uses an IF UPDATE(column) to short circuit if the DML doesn't reference the column the trigger cares about. It also uses the EXCEPT clause for what I've found the fastest way to compare the INSERTED and DELETED tables. Just add more columns to the ...


1

Updates to non-indexed columns don’t modify the index, even if the data row is moved as a consequence of the update, since a forwarding record is left in place. For a heap, a forwarding record is left so nonclustered indexes do not need to be updated. This is done to avoid having to update any non-clustered index records that point back directly to the ...


0

Write a Stored Procedure that 'constructs' the query, specifically by putting a computed value after LIMIT.


Top 50 recent answers are included