Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7783847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:57:42+00:00 2026-06-01T19:57:42+00:00

I have a stream table (memory table), and a script which is inserting in

  • 0

I have a stream table (memory table), and a script which is inserting in this table (from 1 row/min to 100 rows/sec). I need to fetch 1000 rows every 5 seconds, i mean select top 1000 rows and then delete that selected rows.

My select query is so simple:

SELECT * FROM vdp_stream WHERE user=xxx

My problem is actually i cannot query a DELETE sql, because maybe some new rows be appended between the time that i SELECT and DELETE. Am i right? Is there any solution to fetch rows from a table?

UPDATE my table structure:

vdp_stream
---------------------
user CHAR(30)
x    INT
y    INT
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:57:44+00:00Added an answer on June 1, 2026 at 7:57 pm

    If you are going to continue doing this using a table I would suggest using UPDATE, SELECT and DELETE statements within a transaction. Something like this perhaps –

    START TRANSACTION;
    
    UPDATE vdp_stream
    SET selected = 1
    ORDER BY id ASC
    LIMIT 1000;
    
    SELECT *
    FROM vdp_stream
    WHERE selected = 1;
    
    DELETE
    FROM vdp_stream
    WHERE selected = 1;
    
    COMMIT;
    

    UPDATE – as the default isolation level for InnoDB is REPEATABLE READ you can omit the update and just do the SELECT and DELETE based on the same criteria –

    START TRANSACTION;
    
    SELECT *
    FROM vdp_stream
    ORDER BY id ASC
    LIMIT 1000;
    
    DELETE
    FROM vdp_stream
    ORDER BY id ASC
    LIMIT 1000;
    
    COMMIT;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with 4 columns, id , Stream which is text, Duration
I have response stream from a ftp web request that returns binary file. I
I have a stream of bytes which contains a flag which identifies the endianness
I have a stream of data coming in over the serial line from an
I have a incoming stream of bytes (unsigned char) from either a file or
I have a byte stream I need parsed into a struct, and I also
I have a table with 300 million rows in Microsoft SQL Server 2008 R2.
I have a table with an image column in SQL Server 2000. I need
I have Excel spreadsheets stored in a MySQL table longblob field. I need to
I have a sql table which holds information: id (hash) imagename string width int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.