Redian新闻
>
how to get the result in the middle of resultset?
avatar
how to get the result in the middle of resultset?# Database - 数据库
S*s
1
almost every search engine can return the result in the middle of the whole
resultset. say one query returns total 10 k rows. while the use can choose to
have a look only to the rows of number 5000 to 5010.
how to implement this in the databse? is it a must to generate all the top
5010 rows first?
avatar
a*p
2
In some top-level API, like in PHP, you can specify which
line to return when you call function like
mysql_fetch_array
or
odbc_fetch_row
check API documentation. I specified row number in ODBC and mySQL before but
just no source code on hand right now.
but when you select, all the 10k rows should already be in the server's cache.
this method just saves the time to transmit, if say, your mySQL server is remote.

【在 S*******s 的大作中提到】
: almost every search engine can return the result in the middle of the whole
: resultset. say one query returns total 10 k rows. while the use can choose to
: have a look only to the rows of number 5000 to 5010.
: how to implement this in the databse? is it a must to generate all the top
: 5010 rows first?

avatar
a*i
3
Well, that would be EXTREMELY slow if you have to be able to grab all
returnsets first.
For easier implementation; you can use Limit $start, $page functionality.
select * from test_table where test_id > 10 limit 10, 10
will give you 10 results starting from the 10th one.

【在 a*p 的大作中提到】
: In some top-level API, like in PHP, you can specify which
: line to return when you call function like
: mysql_fetch_array
: or
: odbc_fetch_row
: check API documentation. I specified row number in ODBC and mySQL before but
: just no source code on hand right now.
: but when you select, all the 10k rows should already be in the server's cache.
: this method just saves the time to transmit, if say, your mySQL server is remote.

avatar
a*p
4
I don't think the original author doesn't know this solution.
his problem is probably far more complicated.
basically, if you want to query a search engine using sth like
where str like '%you_want%'
and you want the output to be paged.
how can you generate the second/third/etc... pages?

【在 a*****i 的大作中提到】
: Well, that would be EXTREMELY slow if you have to be able to grab all
: returnsets first.
: For easier implementation; you can use Limit $start, $page functionality.
: select * from test_table where test_id > 10 limit 10, 10
: will give you 10 results starting from the 10th one.

avatar
a*i
5
Not sure what you meant, but you can keep track of the pages by specifying
the parameter like dummypage.php?start=0&page=15&total=100.(I have done this,
I know.)
And searching engine is a different story. I think they have used c code
to optimize the middle layer between web and the db.

【在 a*p 的大作中提到】
: I don't think the original author doesn't know this solution.
: his problem is probably far more complicated.
: basically, if you want to query a search engine using sth like
: where str like '%you_want%'
: and you want the output to be paged.
: how can you generate the second/third/etc... pages?

avatar
S*s
6
i think I mentioned "search engine" in my original post.
it is not a problem how the middle layer deal with the
parameter of start and end. the prolem is just as the title.
I don't know the limit function (so atp, what you assumed is
wrong ;). and i still don't understand how it can be used. I
can't find the description of this function from online
document.
the solution I can figure out is with cursor, only those
rows falls into that range was returned, which eleminate the
unnecessary traffice

【在 a*****i 的大作中提到】
: Not sure what you meant, but you can keep track of the pages by specifying
: the parameter like dummypage.php?start=0&page=15&total=100.(I have done this,
: I know.)
: And searching engine is a different story. I think they have used c code
: to optimize the middle layer between web and the db.

avatar
a*p
7
definitely search engine should use more effective code like
C. but probably this is common problem in implementing
search engine.
Well, what I mean is as the following. here in this bbs, you
want to query posts whose titles contain the letter "a" and
definitely you will get lots of results, say, 1000 records
and you defintely don't want all results to be outputted in
one page, so you page it. say, if you want 50 records per
page
It's fairly easy to generate the first page, just using
"limit 50"

【在 S*******s 的大作中提到】
: i think I mentioned "search engine" in my original post.
: it is not a problem how the middle layer deal with the
: parameter of start and end. the prolem is just as the title.
: I don't know the limit function (so atp, what you assumed is
: wrong ;). and i still don't understand how it can be used. I
: can't find the description of this function from online
: document.
: the solution I can figure out is with cursor, only those
: rows falls into that range was returned, which eleminate the
: unnecessary traffice

avatar
S*s
8
1. u both mean that search engine would rather do its own
query algorism than request against a RDBMS ? I strongly
doubt.
if it is not what you meant, I don't see too much difference
of the coding in client side, no matter it is C or not.
2. and do you know if there is the counterpart in MS SQL
Server of the "limit" function you mentioned? is this
function part of ANSI?
3. i think such function helps to those query that can be do
by a single select statment. but to those more complicated
query I

【在 a*p 的大作中提到】
: definitely search engine should use more effective code like
: C. but probably this is common problem in implementing
: search engine.
: Well, what I mean is as the following. here in this bbs, you
: want to query posts whose titles contain the letter "a" and
: definitely you will get lots of results, say, 1000 records
: and you defintely don't want all results to be outputted in
: one page, so you page it. say, if you want 50 records per
: page
: It's fairly easy to generate the first page, just using

avatar
S*s
9
now i got a solution:
temp table. we can do the index in the temp table. then only
return those in the range back to client. according to the
DBA, such operation runs very fast.
so is the solution to my other question. insert the rows
created by cursor into the temp table. return this table at
last.
so simple, hmm?

【在 S*******s 的大作中提到】
: 1. u both mean that search engine would rather do its own
: query algorism than request against a RDBMS ? I strongly
: doubt.
: if it is not what you meant, I don't see too much difference
: of the coding in client side, no matter it is C or not.
: 2. and do you know if there is the counterpart in MS SQL
: Server of the "limit" function you mentioned? is this
: function part of ANSI?
: 3. i think such function helps to those query that can be do
: by a single select statment. but to those more complicated

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。