473,471 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Fastest way to get thousands of db records to client in 3 tier?

Subject says it all... what's the fastest way to get many thousands of
records to the client?

I'm trying to sketch out a traditional 3 tier client-server system.
Multiple clients would make requests to the server. The server should
execute sql select commands against a server-side database, then
return the results to the client.

I tried the standard xmlrpclib and SimpleXMLRPCServer tools that came
with Python. I liked the simplicity, but it was about 30-35 times
slower than executing the sql directly from the client...

I intend to write both client and server in Python, and my main goal
in the first cut is speed. Suggestions?

Alan
Jul 18 '05 #1
9 2261
R. Alan Monroe wrote:

I intend to write both client and server in Python, and my main goal
in the first cut is speed. Suggestions?


Why do you need thousand of rows at the client? Normally you would get
the results in batches, so that you only transfer at most a few hundred
at a time to the client.

I am not saying that you never need to do it. It's just rare. So perhaps
all you need is a change in user-interface?

Anyhoo you can reduce the number of queries/connections to get better
speed. It is easy to inadvertently make queries like:

for i in range(1000):
"select * from table1 where some_number=i;"

Instead of:
"select * from table1 where some_number=<1000;"

Normally it is not as simple as this, but the basic problem is the same.

But if your problem is that you transfer the data over the wire in xml
format and that is too slow, you need to use another format. XML
conversion can have a lot of overhead. Especially if it is many thousand
rows.

Why not let the client ask directly if it is faster?

But if you can bring down the number of rows, using xml might not be a
problem at all.

regards Max M

Jul 18 '05 #2
Hello Alan,
I intend to write both client and server in Python, and my main goal
in the first cut is speed. Suggestions?

Find your bottleneck! (try hotshot)
If it's in the network maybe use socket + pickle + bz2 ?

HTH.
Miki
Jul 18 '05 #3
In article <3f***********************@dread12.news.tele.dk> , Max M <ma**@mxm.dk> wrote:
I intend to write both client and server in Python, and my main goal
in the first cut is speed. Suggestions?
Why do you need thousand of rows at the client? Normally you would get
the results in batches, so that you only transfer at most a few hundred
at a time to the client.
Those types of tests will be done in my second cut.

Why not let the client ask directly if it is faster?


I thought that defeats the purpose of having 3 tiers. You'd have to
update the client if/every time business rules changed. Unless I'm
missing something. Links to tutorials welcome.

Alan
Jul 18 '05 #4
In article <3f***********************@dread12.news.tele.dk> , Max M <ma**@mxm.dk> wrote:
I intend to write both client and server in Python, and my main goal
in the first cut is speed. Suggestions?
Why do you need thousand of rows at the client? Normally you would get
the results in batches, so that you only transfer at most a few hundred
at a time to the client.
Those types of tests will be done in my second cut.

Why not let the client ask directly if it is faster?


I thought that defeats the purpose of having 3 tiers. You'd have to
update the client if/every time business rules changed. Unless I'm
missing something. Links to tutorials welcome.

Alan
Jul 18 '05 #5
am*******@yahoo.com (R. Alan Monroe) writes:
In article <3f***********************@dread12.news.tele.dk> , Max M <ma**@mxm.dk> wrote:
I intend to write both client and server in Python, and my main goal
in the first cut is speed. Suggestions?
Why do you need thousand of rows at the client? Normally you would get
the results in batches, so that you only transfer at most a few hundred
at a time to the client.


Those types of tests will be done in my second cut.


At this stage you should be worrying more about this than about the
details of the protocol and implementation thereof.

Why not let the client ask directly if it is faster?


I thought that defeats the purpose of having 3 tiers. You'd have to
update the client if/every time business rules changed. Unless I'm

[...]

Why? The client asks the client in terms of "business logic", the
server asks the database in SQL. If server and DB can communicate
quickly, no problem.
John
Jul 18 '05 #6
In article <87************@pobox.com>, jj*@pobox.com (John J. Lee) wrote:
>Why not let the client ask directly if it is faster?
I thought that defeats the purpose of having 3 tiers. You'd have to
update the client if/every time business rules changed. Unless I'm[...]

Why? The client asks the client in terms of "business logic", the

^^^^^^^^^^^^^^^^^^^^^^
Not sure what you meant to say here?
server asks the database in SQL. If server and DB can communicate
quickly, no problem.

Let's say I want to see all the tickets I worked on in the previous
calendar year. The server can get this from the DB in 1 second. But if
the server has to spend 30, 60 or more seconds getting those results
back to me, the client, the system wouldn't be worth using, in my
opinion.

I _have_ used systems that returned a subset of matching records to
the client, and found it very uncomfortable. That's why in my system I
want to scratch my own itch, and return all the records.

Alan

Jul 18 '05 #7
> I _have_ used systems that returned a subset of matching records to
the client, and found it very uncomfortable. That's why in my system I
want to scratch my own itch, and return all the records.


Here are some odd ideas:
- Have the server do the original query, but put the results into a table
(temporary table? - depends upon the lifespan of temp tables in your RDBMS),
then let the server hand the client the name of this table. The client then
queries for the records from the location the server gave it. The table the
client queries is a one-time view of the data, thus your server code can do
any joins and logic needed for the biz rules, and the client simple does a
select * on the results.

- Stored procedures. Move some of your biz logic into them, the server will
get simpler, and the occasional client by-pass of the server won't cause
headaches when the biz rules change.

- Warning, this one is ugly: Write the query in such a way that the
results are preformated for transmission between the server and client. For
example, using string concatenation, change your query to return 1 column,
which would contain a pickled object sutable for immediate transmission to
the client. If you're not passing pickled objects, this will be easier,
since you just format the column to contain a valid line/record for sending
to the client.

~Jon Franz
NeuroKode Labs, LLC
Jul 18 '05 #8
R. Alan Monroe wrote:
Subject says it all... what's the fastest way to get many thousands of
records to the client?

I'm trying to sketch out a traditional 3 tier client-server system.
Multiple clients would make requests to the server. The server should
execute sql select commands against a server-side database, then
return the results to the client.

I tried the standard xmlrpclib and SimpleXMLRPCServer tools that came
with Python. I liked the simplicity, but it was about 30-35 times
slower than executing the sql directly from the client...

I intend to write both client and server in Python, and my main goal
in the first cut is speed. Suggestions?

Alan


I suspect that it will be difficult for you to match the speed of using
sql to do direct record retrieval from the client. People who build
databases spend a lot of time and effort making this work as fast as
they can because of its impact on overall database performance.

My suggestion: You need to think harder about your performance versus
functionality trade-offs. E.g., if you're not moving too many records
and the server isn't heavily used, you shouldn't care about the extra
overhead.

On the other hand, if you're moving a lot of records _and_ the server is
heavily used, then you're trying for bleeding edge performance and you
should either expect to spend a lot of time making ugly compromises in
order to meet your requirements or to spend money buying a bigger server
and more communications bandwidth.

Chris

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 18 '05 #9
am*******@yahoo.com (R. Alan Monroe) writes:
In article <87************@pobox.com>, jj*@pobox.com (John J. Lee) wrote:
>Why not let the client ask directly if it is faster? I thought that defeats the purpose of having 3 tiers. You'd have to
update the client if/every time business rules changed. Unless I'm[...]

Why? The client asks the client in terms of "business logic", the

^^^^^^^^^^^^^^^^^^^^^^
Not sure what you meant to say here?


The client asks the server, sorry.

Let's say I want to see all the tickets I worked on in the previous
calendar year. The server can get this from the DB in 1 second. But if
the server has to spend 30, 60 or more seconds getting those results
back to me, the client, the system wouldn't be worth using, in my
opinion.
"So don't do that", was the point that somebody was making. Worry
about the big issue of what network traffic you'll have and how many
round trips, not the small issue of the particular means of transport
of that traffic.

I _have_ used systems that returned a subset of matching records to
the client, and found it very uncomfortable. That's why in my system I
want to scratch my own itch, and return all the records.


Fair enough. Would have to know more to comment.
John
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ratu | last post by:
I'd like to use a stored procedure to insert large amounts of records into a table. My field A should be filled with a given range of numbers. I do the following ... but I'm sure there is a better...
9
by: danny van elsen | last post by:
hello all, I have an application in which I build a list<node>, with potentially thousands of nodes. each node has an "index", and all nodes are ordered by this index. this index reflects a...
2
by: Zambo via SQLMonster.com | last post by:
Hi! We have Sql Server 2000 in our server (NT 4). Our database have now about +350.000 rows with information of images. Table have lot of columns including information about image name, keywords,...
7
by: adm | last post by:
There are a few ways to go about this, but what is the fastest when called from VBA? This if for an ADP with a SQL Server back-end.
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
5
by: johannblake | last post by:
I need to copy all the data from a one dimensional byte array to a specific column in a two dimensional int array. For example: byte byteArray = {4, 5, 6}; int intArray = new int; After...
8
by: Patrick McGuire | last post by:
I have a treeview control on a windows form that I want to populate in the form's load event. The problem is that the datatable I am using to populate it contains >20,000 records, and it takes > 1...
13
by: comp.lang.php | last post by:
I have currently devised a way to display up to 3,000 records via PHP/HTML by using pagination techniques that stuff an entire DB query resultset into a $_SESSION object to use within pagination. ...
5
by: beersa | last post by:
Hi All, I have to query the database with the string from text file. Here are the details: OS: WinXP Home Pro DB: Oracle 9.x The table in DB has 20,000 rows. The text file has 15,000...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.