• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating Temp table and querying it

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I want to search some data in a table which has almost 1 million records. I want to get the data from database and then want to store it in a temp table. Now if next time I need to take data, I will take it from temp table. Example would be.

In a table named people of 1 million records, I want to search for people from New york. Let say the result is 10000 and I want to show only 50 on page. So I will be using pagination for this. Now on next call I dont want to repeat the search, I want to take it from temp table.

How will I achieve this in JDBC and is it a good solution or not?

Thanks in advance.
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a nice discussion of that issue at PaginationOrPaging. Take a look at that, and let us know if you have any other questions.
 
Fawad Ali
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Greg,
I am gonna go through it.
 
Fawad Ali
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Greg,
I went through that discussion. I want t0 achieve a temporary table idea. I am connected to postgreSQL, and I am implementing it in a web based project. I am facing the following problems.

1) The postgreSQL does not support global temporary tables. How can we achieve that? I have posted it on postgreSQL forums as well.
2) If I get the first point to working, I will still be confused. I need to clear few things about temporary tables before implementing those. In my application if I want to search for people from New york and insert rows to temp table named abc_temp. At the same time some other user comes onto that page and he wants to search for people from Washington DC and again the rows are inserted to abc-temp. My question here is that whether we will have tow different tables now differing on session id or the second user's temp table will over write the first user's temp table.

Thanks for your help.

Regards,
dirshah.
 
Greg Charles
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm afraid my experience with Postgres is extremely limited. I know it supports views and even materialized views. It seems to me a snapshot materialized view might get you what you need.

However, that's all in the database. There are constant design battles between application developers and DBDs. I'm an application developer, so the dumber I can make the database layer, the better I like it. I'd either limit the query to the page of data you need, or bring the whole set of data into the user's session, and populate pages as needed from there. Each user has a different session, so they can be paging through different data sets without fear of trampling on each other. If you need multiple users to share data results, adding a second level cache is a good idea. ehcache is the one I'm most familiar with. It's the default cache for Hibernate, but it also works with plain JDBC.

Greg
 
Fawad Ali
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Greg,
Thanks a lot man. Still sounds great. Can you suggest me with some better discussions on how to implement cashes?
reply
    Bookmark Topic Watch Topic
  • New Topic