Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

DataBase search criteria  RSS feed

 
kiranreddy reddy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I need to develop a web page that shows some content that I retrieve from database tables. The content contains a number of rows.But I have to display on the page depending what user chooses.

That is there are 3 0r 4 search parameters and user can change those search parameters and search, then the page should display all the records satisfying those constraints.

For this situation, I need suggestions regarding which is the best way to do,
a)Is it good to connect to DB everytime user searches and retireve the resultset satisfying those constraints
b)Or get all the rows from DB and one time and display on the page depending on the constraints. This sounds good, but I am not sure how I can do it
c) Write all data to an XML document and use XSLT to display only those records that satisfy..

PLz let me know if there are any other good ways of doing this.

Thanks
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your three suggestions are not mutually exclusive.

I would only use (b) if these two conditions applied: the number of records in the database is small, and the database is read-only (i.e. it will not change as long as your server is running). The fact that there are several search parameters suggests that this is not the case.

So in general the best approach is to connect to the database and run a query that returns only the records the user asked for. The database server will throw away unwanted records much more efficiently than your code (Java or XSLT) can, besides which it is preferable not to send unwanted data across the network from the database server to your application server.

Of course there may be features of your database which make the "general" advice not the best, but we don't know much about it.
 
kiranreddy reddy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul thanks for the response

As you rightly said sol(b) is not feasible as the data can change any time,

The solution u recommended is the one that I am using as of now, but I was just wondering if I can reduce the connection overhead everytime user searches.

Thanks
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What "connection overhead" is that?

If you are opening and closing a connection every time you get a request to access the database, then you should stop doing that and configure your application server to have a connection pool.

Or if you are referring to the time it takes to execute a query, then look into tuning your database. You may be able to do simple things such as creating indexes that speed up the queries.
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
use Datasource & Rowset(WebRowset/Filtered Rowset would be efficient)

Shrinivas
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!