New answers tagged delete
-1
votes
MySQL DELETE statement doesn't use index although the same SELECT query does
May be you can try like this:
EXPLAIN DELETE d.* FROM data d WHERE country='Y' and category='X'
1
vote
Accepted
SELECT / DELETE rows where consecutive null value count is greater than N
To just select:
SELECT *
FROM (
SELECT *, count(*) OVER (PARTITION BY receiver, grp) AS grp_count
FROM (
SELECT *, count(recv_time) OVER (PARTITION BY receiver ORDER BY send_time) AS grp
...
0
votes
Keep the foreign key constraint using soft delete
Using soft deletes invariably leads to more complex SQL because you're having to allow for things that exists, but that you want to treat as if they didn't.
That said, it is only one extra element on ...
1
vote
Keep the foreign key constraint using soft delete
You could make <primary key> plus <isdeleted> a composite unique key, and reference that in the foreign keys instead of the primary key, though this would feel a bit dirty to me. You would ...
Top 50 recent answers are included
Related Tags
delete × 445sql-server × 143
mysql × 138
postgresql × 69
performance × 43
foreign-key × 33
innodb × 21
trigger × 21
update × 20
oracle × 19
query-performance × 16
t-sql × 16
sql-server-2012 × 15
join × 15
cascade × 15
sql-server-2008-r2 × 14
insert × 14
database-design × 12
deadlock × 12
duplication × 12
sql-server-2008 × 11
optimization × 11
truncate × 11
sql-server-2014 × 10
sql-server-2016 × 10