473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

speedy code? (with 2 databases)

Hi all!

I cannot share the code, but maybe someone can gibve me an idea...
I have to lookup something in a database (updates from specific time,
MS SQL Server), and check them in another database (Oracle). Both might
contain multiple rows, which makes this big...
The point is, that the code below runs at app 10 rows/second, which is
slow... any ideas how I can do it better?

The slow thing is that for each row in DB1, I run a query in DB2.

The code is basically this - there is some more, but

// get data from MS SQL
$result2=odbc_exec($conn2, $sql);

while(odbc_fetch_row($result2) )
{
// test for this is Oracle DB (here might be multiple rows too)
$sql2= select....
$result=odbc_exec($conn, $sql2);

// if row exist
while(odbc_fetch_row($result))
//if(odbc_num_rows($result)>1)
{
// add to array - for next step to search - do not add twice
$k=count($part1)-1;
while(($k>-1) && ($part1[$k]!=odbc_result($result2,1)) &&
($part2[$k]!=odbc_result($result2,2)) &&
$part8[$k]!=trim(odbc_result($result,1)))
$k--;
if($k==-1)
{
$part1[]=trim(odbc_result($result2,1));
$part2[]=trim(odbc_result($result2,2));
$part3[]=trim(odbc_result($result2,3));
$part4[]

ASO....

Oct 12 '06 #1
2 1233
Sonnich wrote:
The slow thing is that for each row in DB1, I run a query in DB2.

The code is basically this - there is some more, but
Try this:
// get data from MS SQL
$result2=odbc_exec($conn2, $sql);

while(odbc_fetch_row($result2) )
{
$MSSQLarr[] = odbc_result();
}

// Oracle SQL
$ORACLEsql = "select ... where RECORDID in (" . implode(',', $MSSQLarr) . ") ...";

# // test for this is Oracle DB (here might be multiple rows too)
# $sql2= select....
# $result=odbc_exec($conn, $sql2);
#>
# // if row exist
# while(odbc_fetch_row($result))
# //if(odbc_num_rows($result)>1)
# {
# // add to array - for next step to search - do not add twice
# $k=count($part1)-1;
# while(($k>-1) && ($part1[$k]!=odbc_result($result2,1)) &&
#($part2[$k]!=odbc_result($result2,2)) &&
#$part8[$k]!=trim(odbc_result($result,1)))
# $k--;
# if($k==-1)
# {
$part1[]=trim(odbc_result($result2,1));
$part2[]=trim(odbc_result($result2,2));
$part3[]=trim(odbc_result($result2,3));
$part4[]
So, if MSSQL returns 42 rows, instead of 43 queries (1 on MSSQL + 42 on
Oracle) you do 2 queries only.

--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot
Oct 12 '06 #2

Pedro Graca wrote:
Sonnich wrote:
The slow thing is that for each row in DB1, I run a query in DB2.

The code is basically this - there is some more, but

Try this:
// get data from MS SQL
$result2=odbc_exec($conn2, $sql);

while(odbc_fetch_row($result2) )
{
$MSSQLarr[] = odbc_result();
}

// Oracle SQL
$ORACLEsql = "select ... where RECORDID in (" . implode(',', $MSSQLarr) . ") ...";
snip
So, if MSSQL returns 42 rows, instead of 43 queries (1 on MSSQL + 42 on
Oracle) you do 2 queries only.
I like the idea, but if:

$sql = ..... where code = '1234' and version = '03';

The in would return a lot more than I want :-)

Br
S

Oct 13 '06 #3

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

Similar topics

11
by: Joshua Beall | last post by:
Hi All, I am working on a registration system, and one of the things I am going to need to be able to do it setup the database tables for each event that I have registration for. Normally I...
10
by: David | last post by:
Does anyone know where I can find example code for VB.NET that I can use to create an application that attaches and detaches databases to MSDE using osql scipts. (I think SQL-DMO is typically...
0
by: Murray Bryant | last post by:
I am having problems with contrib/tablefunc in postgresql 7.4.1 on freebsd when i try to make install i get the errors below. I am unable to make the 7.3 -> 7.4 transition until i can get the...
3
by: Amit | last post by:
Hi when I try to run LIST ACTIVE DATABASES AT DBPARTITIONNUM <partnum> or LIST ACTIVE DATABASES GLOBAL, I always get an error message. Does anyone know why? I'm on v8 fp 5 output : db2 => list...
1
by: Andrew | last post by:
Hi Group! I'm looking for a tutorial in using SQL-DMO, or some sample code that will allow me to let my users switch the SQL Server database that the front end app is linking to as a back end. ...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
6
by: John | last post by:
Hi I have a front-end/back-end access app. I have created a replication set between the backend on a server an the backend on a laptop. My question is; How can I cause the synchronisation to...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
3
by: Henners | last post by:
Hi There We are migrating our network file system from Novell to Windows. (There are pros and cons).... In this process, we have noticed that a good bunch of user created access databases...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.