Showing posts with label number. Show all posts
Showing posts with label number. Show all posts

Thursday, March 22, 2012

A way to control the # of Transport connections

Is there a configuration parameter that allows me to control the number of Transport connections used by service broker? Right now it seems that it just uses one.

There is no such configuration parameter. The only reason to use more than one TCP connection would be if there were multiple NICs having routes to the destination. But since Service Broker does not really bottleneck on the NIC, there was no reaon to add support for multiple TCP connections. However, we may add this support for other reasons.

Rushi

|||

Ok so what should I do if it feels like I am being constrained at around 100 - 150 messages per second through this transport piece? I have done a couple of tests and at one point it seemed if I enqueued more than 100 messages/sec then they would back up into the sys.transmission_queue on the source side. I realize that is by design, but I have been led to believe that I should get something closer to 1,000 messages/sec of throughput between the 2 instances?

Any thoughts?

sql

Saturday, February 25, 2012

A question on JOIN

Hi, guys,

I am confused by JOIN s. It said JOIN would hurt queryperformance. So is there some limit of number of JOIN s in a query, say if yourquery has more than 3 joins, the performance would be hurt? And why?

Is there an alternate method of JOIN? I tried sub query, itseems the execution plans are the same.

another option to join would be to use UNION, but I think the performance would be the same or possibly worse using that.

Your joins will be affected less if you can specify how it joins on more than one parameter (If I recall correctly)..

SELECT * FROM maintable mt

INNER JOIN table t ON t.ID= mt.ID AND t.another_parameter=mt.another_parameter AND t.secondparam=mt.second_param AND t.thisfield='whatever'

WHERE mt.thisfield='whatever'

The more you filter it down, the less the query will have to scan the dataobject for results.

|||

Well the maximum number of tables per select statement is 256 for SQL Server. NORMALLY joins will have better performance than sub-queries as joins use relational algebra. Some people will say they only use joins if they need a field from the table they are joining into, but i normally use them over a sub-query(there are situations where a subquery is fatser or needed).

Also it matters what you are joining on, if you join on a text field or a non indexed field it will hurt query performance.

|||

The speed of a JOIN is more influenced by the number of rows in both sources of the join, and the number of rows in the result. Using the correct indexes can speed up the JOIN. I've seen multi-minute queries sped up by a single index to sub-second responses by the correct use of indexes, and I'm sure there is even better results (and worse).

|||

As Motley points out, what matters are proper indexing and the actual number of rows being returned by tables in each join condition. I have had 8 table joins with sub-second response time where all the tables are being selected based on a primary key value.

There is no alternative to a join in the sense that if you have normalized data, you're going to have to join the tables to get the data. There is NO reason to avoid joins, even ones involving many tables.

|||

Got it.

Guys, Thanks.

|||

how bout creating the joins in a view as opposed to creating it in a stored procedure? will this improve performance?

|||

Not unless it's an indexed/materialized view, no.

Friday, February 24, 2012

a question about sp_monitor

On the Books Online for sp_monitor:
total_read Number of reads by SQL Server.
total_write Number of writes by SQL Server.
Can anybody explain what is Number of Reads/Writes mean? Is it the number of
bytes read/Write?
Thanks,
LijunThey are same as @.@.total_read (or @.@.total_write), and they are the total
number of disk reads (or writes) by SQL Server since it starts. So they are
definitely not the number of bytes read or written.
I don't use sp_monitor, and I don't know anybody who uses sp_monitor for any
sort of practical performance tuning or troubleshooting purposes.
Linchi
"Lijun Zhang" wrote:

> On the Books Online for sp_monitor:
> total_read Number of reads by SQL Server.
> total_write Number of writes by SQL Server.
>
> Can anybody explain what is Number of Reads/Writes mean? Is it the number
of
> bytes read/Write?
> Thanks,
> Lijun
>
>|||Thanks, Linchi. What I am trying to do is to get number of bytes read/write
for a period of time. We are looking at buy a new server to replace one of
the production servers, and I am trying to get the bandwidth requirements.
Do you know how to get the counters? Is System Monitor the only tool I can
use?
Lijun
"Linchi Shea" <LinchiShea@.discussions.microsoft.com> wrote in message
news:4E872DCB-ADB7-4CFD-85FB-44F4A73035F7@.microsoft.com...[vbcol=seagreen]
> They are same as @.@.total_read (or @.@.total_write), and they are the total
> number of disk reads (or writes) by SQL Server since it starts. So they
> are
> definitely not the number of bytes read or written.
> I don't use sp_monitor, and I don't know anybody who uses sp_monitor for
> any
> sort of practical performance tuning or troubleshooting purposes.
> Linchi
> "Lijun Zhang" wrote:
>|||That won't tell you any kind of bandwidth. Exactly what are you trying to
determine the server or the storage?
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"Lijun Zhang" <sonyzhang00@.yahoo.com> wrote in message
news:e%23ndhA8SIHA.2000@.TK2MSFTNGP05.phx.gbl...
> Thanks, Linchi. What I am trying to do is to get number of bytes
> read/write for a period of time. We are looking at buy a new server to
> replace one of the production servers, and I am trying to get the
> bandwidth requirements.
> Do you know how to get the counters? Is System Monitor the only tool I can
> use?
> Lijun
>
> "Linchi Shea" <LinchiShea@.discussions.microsoft.com> wrote in message
> news:4E872DCB-ADB7-4CFD-85FB-44F4A73035F7@.microsoft.com...
>

a question about sp_monitor

On the Books Online for sp_monitor:
total_read Number of reads by SQL Server.
total_write Number of writes by SQL Server.
Can anybody explain what is Number of Reads/Writes mean? Is it the number of
bytes read/Write?
Thanks,
Lijun
They are same as @.@.total_read (or @.@.total_write), and they are the total
number of disk reads (or writes) by SQL Server since it starts. So they are
definitely not the number of bytes read or written.
I don't use sp_monitor, and I don't know anybody who uses sp_monitor for any
sort of practical performance tuning or troubleshooting purposes.
Linchi
"Lijun Zhang" wrote:

> On the Books Online for sp_monitor:
> total_read Number of reads by SQL Server.
> total_write Number of writes by SQL Server.
>
> Can anybody explain what is Number of Reads/Writes mean? Is it the number of
> bytes read/Write?
> Thanks,
> Lijun
>
>
|||Thanks, Linchi. What I am trying to do is to get number of bytes read/write
for a period of time. We are looking at buy a new server to replace one of
the production servers, and I am trying to get the bandwidth requirements.
Do you know how to get the counters? Is System Monitor the only tool I can
use?
Lijun
"Linchi Shea" <LinchiShea@.discussions.microsoft.com> wrote in message
news:4E872DCB-ADB7-4CFD-85FB-44F4A73035F7@.microsoft.com...[vbcol=seagreen]
> They are same as @.@.total_read (or @.@.total_write), and they are the total
> number of disk reads (or writes) by SQL Server since it starts. So they
> are
> definitely not the number of bytes read or written.
> I don't use sp_monitor, and I don't know anybody who uses sp_monitor for
> any
> sort of practical performance tuning or troubleshooting purposes.
> Linchi
> "Lijun Zhang" wrote:
|||That won't tell you any kind of bandwidth. Exactly what are you trying to
determine the server or the storage?
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"Lijun Zhang" <sonyzhang00@.yahoo.com> wrote in message
news:e%23ndhA8SIHA.2000@.TK2MSFTNGP05.phx.gbl...
> Thanks, Linchi. What I am trying to do is to get number of bytes
> read/write for a period of time. We are looking at buy a new server to
> replace one of the production servers, and I am trying to get the
> bandwidth requirements.
> Do you know how to get the counters? Is System Monitor the only tool I can
> use?
> Lijun
>
> "Linchi Shea" <LinchiShea@.discussions.microsoft.com> wrote in message
> news:4E872DCB-ADB7-4CFD-85FB-44F4A73035F7@.microsoft.com...
>

a question about sp_monitor

On the Books Online for sp_monitor:
total_read Number of reads by SQL Server.
total_write Number of writes by SQL Server.
Can anybody explain what is Number of Reads/Writes mean? Is it the number of
bytes read/Write?
Thanks,
LijunThey are same as @.@.total_read (or @.@.total_write), and they are the total
number of disk reads (or writes) by SQL Server since it starts. So they are
definitely not the number of bytes read or written.
I don't use sp_monitor, and I don't know anybody who uses sp_monitor for any
sort of practical performance tuning or troubleshooting purposes.
Linchi
"Lijun Zhang" wrote:
> On the Books Online for sp_monitor:
> total_read Number of reads by SQL Server.
> total_write Number of writes by SQL Server.
>
> Can anybody explain what is Number of Reads/Writes mean? Is it the number of
> bytes read/Write?
> Thanks,
> Lijun
>
>|||Thanks, Linchi. What I am trying to do is to get number of bytes read/write
for a period of time. We are looking at buy a new server to replace one of
the production servers, and I am trying to get the bandwidth requirements.
Do you know how to get the counters? Is System Monitor the only tool I can
use?
Lijun
"Linchi Shea" <LinchiShea@.discussions.microsoft.com> wrote in message
news:4E872DCB-ADB7-4CFD-85FB-44F4A73035F7@.microsoft.com...
> They are same as @.@.total_read (or @.@.total_write), and they are the total
> number of disk reads (or writes) by SQL Server since it starts. So they
> are
> definitely not the number of bytes read or written.
> I don't use sp_monitor, and I don't know anybody who uses sp_monitor for
> any
> sort of practical performance tuning or troubleshooting purposes.
> Linchi
> "Lijun Zhang" wrote:
>> On the Books Online for sp_monitor:
>> total_read Number of reads by SQL Server.
>> total_write Number of writes by SQL Server.
>>
>> Can anybody explain what is Number of Reads/Writes mean? Is it the number
>> of
>> bytes read/Write?
>> Thanks,
>> Lijun
>>|||That won't tell you any kind of bandwidth. Exactly what are you trying to
determine the server or the storage?
--
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"Lijun Zhang" <sonyzhang00@.yahoo.com> wrote in message
news:e%23ndhA8SIHA.2000@.TK2MSFTNGP05.phx.gbl...
> Thanks, Linchi. What I am trying to do is to get number of bytes
> read/write for a period of time. We are looking at buy a new server to
> replace one of the production servers, and I am trying to get the
> bandwidth requirements.
> Do you know how to get the counters? Is System Monitor the only tool I can
> use?
> Lijun
>
> "Linchi Shea" <LinchiShea@.discussions.microsoft.com> wrote in message
> news:4E872DCB-ADB7-4CFD-85FB-44F4A73035F7@.microsoft.com...
>> They are same as @.@.total_read (or @.@.total_write), and they are the total
>> number of disk reads (or writes) by SQL Server since it starts. So they
>> are
>> definitely not the number of bytes read or written.
>> I don't use sp_monitor, and I don't know anybody who uses sp_monitor for
>> any
>> sort of practical performance tuning or troubleshooting purposes.
>> Linchi
>> "Lijun Zhang" wrote:
>> On the Books Online for sp_monitor:
>> total_read Number of reads by SQL Server.
>> total_write Number of writes by SQL Server.
>>
>> Can anybody explain what is Number of Reads/Writes mean? Is it the
>> number of
>> bytes read/Write?
>> Thanks,
>> Lijun
>>
>

Thursday, February 16, 2012

A problem in memory when I run sp with a large number of records !

I will describe my problem and I hope that you will help me to find the way to solve it !

My task is how to find the "similiar" words in our database ! Now, I have to use my software to find the similiar name. For example :

The name : "Donaldson Filtration Slovensko s.r." and the name : "PENTA Slovensko Donaldsin spol. sro" are "similiar". In that case : the word "Donaldson" and "Donaldsin" can be called similiar because they are diffrence not more one character in the same positon in the string.

I used stored procedure to sovle this problem because it is a larg number of records in each table (for over 1 million records for each table).

The way I had used first is create a temperary table to contain

CREATE TABLE #SeperateString1
(
String1 nvarchar(100)
)

CREATE TABLE #SeperateString2
(
String2 nvarchar(100)
)

So that, I will analyze those string into 2 tables by detecting the blank character between 2 words !

Then, I compare values between 2 tables,

_

DECLARE ST1_Cursor CURSOR FOR
SELECT String1 FROM #SeperateString1
OPEN ST1_Cursor

FETCH NEXT FROM ST1_Cursor INTO @.String1
WHILE @.@.FETCH_STATUS = 0
Begin

DECLARE ST2_Cursor CURSOR FOR
SELECT String2 FROM #SeperateString2
OPEN ST2_Cursor

FETCH NEXT FROM ST2_Cursor INTO @.String2
WHILE @.@.FETCH_STATUS = 0
Begin

Exec CompareString @.String1, @.String2, @.Result = @.KetQua Output

If @.KetQua = 1
Begin
Exec SetCol1 @.ID, @.Rescol1 = @.Rescol1 Output
Exec SetCol2 @.IDCI, @.Rescol2 = @.Rescol2 Output
Select @.ResCol3 = 'Name: '+ Char(13) + Char(10) + @.String1 + ' <==> ' + @.String2
Select @.ResCol4 = 0

Select @.ResCol5 = GetDate()

If (Not Exists(Select * From Result Where IAdata like @.ResCol1 And DataFound like @.ResCol2 And Reason like @.Rescol3)) And (Not Exists(Select * From Dictionary Where Value = @.String1)) And (Not Exists(Select * From Dictionary Where Value = @.String2))
Begin
INSERT INTO Result (IAData, DataFound, Reason, Decide, DateNow) VALUES (@.ResCol1, @.ResCol2, @.ResCol3, @.ResCol4, @.ResCol5)
End

End
FETCH NEXT FROM ST2_Cursor INTO @.String2
End

CLOSE ST2_Cursor
DEALLOCATE ST2_Cursor

FETCH NEXT FROM ST1_Cursor INTO @.String1
End


CLOSE ST1_Cursor
DEALLOCATE ST1_Cursor

__
Results will be add to "Result" table

After that, I will deallocate my temporary tables which I have created.

_
drop table #SeperateString1
drop table #SeperateString2
_

This SP will be run in about 3 hours !
Problems occour is memory ! For about an hour to run, my memory I detected in "Task Manger" grown up to 200MB --> 300 MB (Amazing and suprised !) and my computer "run" slowlier than before ! I don't know why ! Can you help me to explain.

For me, the way to explain in this case is Microsoft SQL Server 2000, he was not able to free memory after each session, it was still in my RAM (and even over my RAM, because there is no room to contain them)! So that, it was grown up in an amazing way !

My solution in this case is use an array of string to compare (not simulate a virtual array)! But, in data type of SP not have "array" !

What can I do now ? Please help me to find the way to solve this problem, thanks for all !

I think the fuzzy lookup and fuzzy grouping transforms in Integration Services work very well for solving problems like the one you described. If you need more details, here is the Integration Services dedicated forum: http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=80&SiteID=1

Hope this helps

|||

Thanx to Bogdan Crivat on your suggest,

I tried to find Integration Services from your link of forum and found out that I can use this thing :

go

sp_configure 'show advanced options', 1

go

reconfigure

go

sp_configure 'max server memory', 400

go

reconfigure

go

sp_configure 'min server memory', 100

go

reconfigure

go

But, It is does not apply to maximize my memory, it is over 400 when I run my program !

Note : I use Microsoft SQL Server 2000 in Windows XP SP2.

Regards,

Tran Quang Phuong.

A new PL/SQL nut...

I'm using Oracle, BTW...

Now...: This one is working, thanks to andrewst.

create or replace procedure upd_balance (p_pnr number,p_amount number)
is
begin
update player
set balance=balance+p_amount
where pnr=p_pnr;
end upd_balance;
/

But, I'd like this procedure to do one more thing for me:

insert into trans values(v_next,p_amount,[todays date],p_ttype,p_pnr,'Y');

...given that the "p_ttype" attribute is sent with the exec command, and
..."v_next" is "select max(tnr)+1 from trans;", and
...[todays date] is SYSDATE

Here's the output of "desc trans;"
Name Null? Type
------------- --- ----
TNR NOT NULL NUMBER(5)
AMOUNT NUMBER(7,2)
TDATE DATE
TTNR NUMBER(2)
PNR NUMBER(2)
OK CHAR(1)

CAN SOMEONE MAKE THIS HAPPEN? I'd be ever so grateful.

BR, hermasito.Hello hermasito,

what do you think about

create or replace procedure upd_balance (p_pnr number,p_amount number, p_next number, p_ttype number, p_today DATE)
is
v_next NUMBER := NULL;
v_ttype NUMBER := NULL;
begin

update player
set balance=balance+p_amount
where pnr=p_pnr;

select max(tnr) + 1 INTO v_next from trans;",

IF v_next = p_next AND TO_CHAR(p_today, 'YYYYMMDD') = TO_CHAR(SYSDATE, 'YYYYMMDD') THEN
v_ttype := p_ttype;
END IF;

insert into trans values(p_next, p_amount, SYSDATE, v_ttype, p_pnt, 'Y');

end upd_balance;

Hope that helps a little bit ?

Best regards
Manfred
(Alligator Company GmbH)
http://www.alligatorsql.com|||Well, the insert statement is simple enough - but you MUST specify the columns like this:

INSERT INTO trans (tnr, amount, tdate, ttnr, pnr, ok)
VALUES( v_next, p_amount, SYSDATE, p_ttype, p_pnr, 'Y' );

... otherwise your code may fail some time in the future (e.g. if a new column is added to table TRANS).

(Note: SYSDATE includes time. If you want JUST the date use TRUNC(SYSDATE))

Now, how to get the v_next value. You should be aware that this MAX(trn)+1 solution is not a good idea at all unless your application is single user, because it locks out other users from inserting any data into TRANS until the first user commits. In a multi-user system, all your users will experience potentially long waits to get the next tnr value for their inserts. The correct solution is to use a SEQUENCE:

CREATE SEQUENCE tnr_seq;

Then in your trigger:

INSERT INTO trans (tnr, amount, tdate, ttnr, pnr, ok)
VALUES( tnr_seq.NEXTVAL, p_amount, SYSDATE, p_ttype, p_pnr, 'Y' );

You will have to accept when you use sequences that there WILL be gaps in the numbers, they CANNOT be guaranteed to be sequential. You have to accept that this doesn't matter (it really doesn't matter -an ID is just an ID - but when people are used to gap-free numbers they THINK it matters!) It is this "no gap-free guarantee" feature that makes sequences work efficiently for multi-user systems.

If after reading all the above you still want to use MAX(tnr)+1, then all you have to do is:

SELECT MAX(trn)+1
INTO v_next
FROM trans;

INSERT INTO trans( tnr,...) VALUES (v_next,...);

But don't say I didn't warn you!

Monday, February 13, 2012

A more consistant Web Report Viewer?

Is there another way of displaying reports online that will show the data exactly as it wil be printed?

A number of things have been causing me problems, such as the fact that the pagination controls do not show the same number of pages that actualy get printed. And some fields in the the report viewer do not line up with their column headers, but on the print outs they do.

We used to use Crystal reports, and would like the report viewer to act in a similar manor to their ActiveX report viewer.

Any help is greatly apprechiated.

Many thanks

Matt

I am kindof shooting from the hip here without looking into it too deeply, but I am pretty sure that you can specify CSS as they apply to viewed reports. In doing so, there should be a "print.css", which can be altered as well. This may not be the solution that you are looking for, but I think that it would merit some looking in to.

Hope this helps a bit,

Nathan

|||

Hi Nathan,

Thanks for your comments, but thats not exactly what i was after.

I just had a thought though, there obvously is an activex control that can render the report as this is launched in the print preview.

Does anybody know how to use this renderer as the viewer embeded in a HTML page?

Cheers

Matt

|||

Hi Matt,

Print uses the EMF image extension. You can find the details here: http://msdn2.microsoft.com/en-us/library/ms155373.aspx

If you set the PageHeight and PageWidth properties of your report and use the same margins, this will make the web viewer more similar to the view of Print.

|||You can try displaying the EMF yourself, but I would guess that PDF might be more useable since you don't need to actually write an application to display it. For EMF, you are going to have to write something actually display the metafile that we send.|||

Hi Guys,

Thanks for your feedback.

Brad: I have played around with the Page propeties, however i could not get them to match the printouts exactly (which in this instance is what i need to be able to do), but thanks for the details on EMF, i'll definatley look into it.

John: I will look at how viable using PDF is in our situation, but i think the EMF file might be the way i have to go.

Does anybody have any info on converting a report into and EMF file?

Thanks again guys

Matt

Thursday, February 9, 2012

A function to return number of records

Hello everyone,
I am trying to write a function that returns the number of records present in a table. But in this case i want to pass 'TABLENAME' as a parameter to this function and then retrieve numrecords henceforth.
This is how I'm currently trying to retrieve it -->

FUNCTION GetNumRecords(@.tablename as nvarchar(20))
return int as
begin
Declare @.numrecs as int
Set @.numrecs = (Select Count(*) from @.tablename)
return @.numrecs
end

I'm getting the following error:

--
Must declare the variable '@.tablename'.
--

But i am already passing @.tablename as a parameter to the function and I dont exactly understand where the problem is!! Why can't I use a local variable in a SELECT statement like this.

Any input is highly appreciated,
Thank you.use execute|||Or use:

SELECT @.numrecs = rowcnt FROM sysindexes
WHERE id = object_id(@.TableName)
AND indid in (0,1)

Each table must have at least 1 entry in sysindexes.
If the table has the clustered index, its indid will be 1.
If the table has no clustered, it will have a record with indid = 0.|||I'm afraid you're confusing SQL Server and Oracle syntax

Never use: DECLARE variable_name AS datatype
but instead: DECLARE variable_name datatype|||Refer to this link (http://www.sql-server-performance.com/forum/topic.asp?TOPIC_ID=280) to get the result.