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 8384003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:18:21+00:00 2026-06-09T17:18:21+00:00

I need to create an HTML table with pagination. The data comes from 2

  • 0

I need to create an HTML table with pagination. The data comes from 2 different sources (could be 2 tables from 2 different databases like one Oracle and another is MySQL) which you can’t use joined select statement. To make it more complicated, I need to display the data sorted by timestamp (one of the property is timestamp) in ascending order.

For example, source A has 45 records, source B has 55 records. So the table will display total records of 100, but only display let’s say 15 records at a time. So there has to be 7 pages (6 pages with 15 records and 1 page with 10 records).

The above example are just a total of 100 records which might be easy for the memory to load them all. But in actual production, it could be thousands or millions records. Does anyone know any algorithm that I can use? The parameters that I can provide are page number and the number of record per page.

  • 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-09T17:18:22+00:00Added an answer on June 9, 2026 at 5:18 pm

    As I understand, your concern is memory.

    If individual tables (A and B) are not sorted by timestamp then you need to merge all their records into one file and then use some file-based sorting algorithm (something like MergeSort, in one pass you get sorted pairs of records, in the 2nd pass you get sorted 4s etc.). When you have a file with all the records in ascending order of timestamps you can break it into pages.

    If the tables are already sorted than you need to merge N sorted sequences into one. I suggest you organize some kind of a Heap to keep track of which of N sources has the item with the smallest timestamp. In pseudocode it would look like this:

    for i=1,N
    {
      Add the 1st record from each table to the Heap
    }
    while(Heap not empty)
    {
      x = take the smallest item from the heap, noting which table j this record belonged to
      Add x to output
      if (the j-th table is not completely processed)
      {
        take the next value from the j-th table and insert it into the heap
      }
    }
    

    The complexity is O(M*logN) where M is the total number of records in the tables and N is the number of tables. This whole Heap thing is only worth the hassle if N is sufficiently large (my guess is ~100). Otherwise I would go with linear search and O(N*M).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create more than one UIView with MARQUEE effect like HTML <marquee>
I need to create lines like this: <li data-target=c1.html><span>I. </span><span>Het tijdperk der goden</span></li> I
I need to create a log file containing HTML (tables, etc). It seems that
I need to create a large table of contents for an HTML book but
I need to create a dynamic html table using PHP after parsing a JSON
I have a component that create dynamically html table. According to my need, I
I have an html table that pulls data from a DB. It has an
I need to frame a json object from an html table with all the
I need to create an HTML table which has fixed column widths, say 200px
i need to create an html report where i've to put a table into.

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.