This is a discussion on Sybase FAQ: 1/19 - index within the Tech FAQ forums, part of the Interviews and Job Listings category; Archive-name: databases/sybase-faq/part1 URL: http://www.isug.com/Sybase_FAQ Version: 1.7 Maintainer: David Owen Last-modified: ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Sybase FAQ: 1/19 - index
Archive-name: databases/sybase-faq/part1
URL: http://www.isug.com/Sybase_FAQ Version: 1.7 Maintainer: David Owen Last-modified: 2003/03/02 Posting-Frequency: posted every 3rd month A how-to-find-the-FAQ article is posted on the intervening months. Sybase Frequently Asked Questions Sybase FAQ Home PageAdaptive Server Enterprise FAQAdaptive Server Anywhere FAQ Replication Server FAQSearch the FAQ Sybase FAQ Main Page * Where can I get the latest release of this FAQ? * What's new in this release? * How can I help with the FAQ? * Who do I tell about problems in the FAQ? * Acknowledgements and Thanks * Hall of Fame * Copyright and Disclaimer * General Index Main | ASE | ASA | REP | Search ------------------------------------------------------------------------------- Where can I get the latest release of this FAQ? International Sybase User Group The main page for this site is http://www.isug.com/Sybase_FAQ. It is hosted there by kind permission of the International Sybase User Group (http:// www.isug.com) as a service to the Sybase community. To get a text version of this FAQ: ftp://ftp.midsomer.org/pub/FAQ_txt_tar.Z or ftp://ftp.midsomer.org/pub/FAQ_txt.zip If you want uncompressed versions of the various sections, they can be got from ASE, ASA & REP. To get the HTML for this FAQ: ftp://ftp.midsomer.org/pub/FAQ_html_tar.Z or ftp://ftp.midsomer.org/pub/FAQ_html.zip Last major update: 21st February 2003. Back to Top ------------------------------------------------------------------------------- What's new in this release? Release 1.9 * Running multiple servers on a single server (UNIX and NT). Back to Top ------------------------------------------------------------------------------- What's happening with the FAQ? I have not had a lot of time to spend on the FAQ this year. Mainly, this is down to work, or the lack of it. I know, we are all in the same boat. Well, it has meant that I have had a lot less free time than I used to and as a result the FAQ has not been kept as up to date as I would like. Sadly, the work I have been doing is with those other database vendors, but we won't name them here. Anyway, that is the sob story over and done with. If anyone thinks that they would like to see more effort applied, I would be happy to hand the mantle over. Since the amount of help that I have actually seen amounts to about practically none, then I am sure I will not be over-run with offers! I will definitely have more time come January and plan some serious work on it then. Back to Top ------------------------------------------------------------------------------- How can I help with the FAQ? I have had offers from a couple of people to write sections, but if you feel that you are in a position to add support for a section, or if you have some FAQs to add, please let me know. This is a resource that we should all support, so send me the stuff and I will include it. Typos and specific corrections are always very useful. Less useful is the general I don't think that section x.y.z is very understandable. Sorry to sound harsh, but what I need is actual text that is more readable. Better still is actual HTML that makes it stand out and sing (if necessary)! Currently I am looking for maintainers of the following sections Replication, Adaptive Server Anywhere, IQ server, MPP Server and Open Server. I am not sure whether to add a section for Omni Server. I sort of feel that since Omni has been subsumed into ASE as CIS that any FAQs should really be incorporated there. However, if you know of some good Omni gotchas or tips, whether they are still there in CIS or not, please send them in. I certainly plan to have a subsection of ASE dealing with CIS even if Omni does not get its own major section. I also think that we need sections on some of the really new stuff. Jaguar and the new engines also deserve a spot. Another very useful way that you can help is in getting people to update their links. I have seen lots of links recently, some still pointing to Pablo's original, some pointing to Tom's site but referring to it as coming from the SGI site. Back to Top ------------------------------------------------------------------------------- Who do I tell about problems in the FAQ? The current maintainer is David Owen ( dowen@midsomer.org) and you can send errors in the FAQ directly to me. If you have an FAQ item (both the question and the answer) send it to sybfaq@midsomer.org and I will include it. Do not send email to any of the officials at ISUG, they are simply hosting the FAQ and are not responsible for its contents. Also, do not send email to Sybase, they are not responsible for the contents either. See the Disclaimer. Back to Top ------------------------------------------------------------------------------- Acknowledgements and Thanks Special thanks must go to the following people for their help in getting this FAQ to where it is today. * Pablo Sanchez for getting the FAQ off the ground in the first place and for many years of dedicated work in maintaining it. * Anthony Mandic (am@peppler.org) for a million things. Patiently answering questions in all of the Sybase news groups, without which most beginners would be lost. For supporting and encouraging me in getting this FAQ together and for providing some pretty neat graphics. * The ISUG, especially Luc Van der Veurst (lucv@az.vub.ac.be) and Michael Peppler (mpeppler@peppler.org), for hosting this FAQ and providing support in setting up the website. * The members of the various news groups and mailing lists who, like Anthony, provide unstinting support. The list is fairly long, but I think that Bret Halford (bret@sybase.com) deserves a mention. If you go to Google News and do a search, he submits almost as many replies as Anthony. Back to Top ------------------------------------------------------------------------------- Hall of Fame I am not sure how Pablo chose his select list, there is certainly no question as to their inclusion. I know that there are a couple of awards that the ISUG give out each year for the people that the ISUG members believe have contributed most to the Sybase community that year. I think that this section should honour those people that deserve an award each and every year. If you know of a candidate, let me know and I will consider his or her inclusion. Self nominations are not acceptable :-) The following people have made it to the Sybase FAQ Hall of Fame: * Michael Peppler (mpeppler@peppler.org) For Sybperl and all of the other tools of which he is author or instigator plus the ceaseless support that he provides through countless mailing lists, newsgroups and directly via email. * Scott Gray (gray@voicenet.com) Father of sqsh, much more than simply a replacement for isql. How anyone developing or administering Sybase can survive without it, I will never know. * Pablo Sanchez ( www.hpdbe.com) Pablo got the first web based FAQ off the ground, wrote most (all?) of the first edition and then maintained it for a number of years. He did a fantastic job, building a resource that is worth its weight in gold. Back to Top ------------------------------------------------------------------------------- Copyright and Disclaimer Distribution You are free to copy or distribute this FAQ in whole or in part, on any medium you choose provided that you: * include this Copyright and Disclaimer notice; * do NOT distribute or copy, in any fashion, with the intention of making a profit from its use; * give FULL attribution to the original authors. Disclaimer This FAQ is provided as is without any express or implied warranties. Whilst every endeavour has been taken to ensure the accuracy of the information contained within the articles, the author, nor any of the contributors, assume responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. If you are not happy about performing any of the suggestions contained within this FAQ, you are probably better off calling Sybase Technical Support. Copyright This site and all its contents belongs to the Sybase FAQ (http://www.isug.com/ Sybase_FAQ). Unless explicitly stated in an article, all material within this FAQ is copyrighted. The primary copyright holders are David Owen and Pablo Sanchez. However, all contributed material is, and will remain, the property of the respective authors and contributors. Back to Top ------------------------------------------------------------------------------- ASE 1.1: Basic ASE Administration 1.1.1 What is SQL Server and ASE anyway? 1.1.2 How do I start/stop ASE when the CPU reboots? 1.1.3 How do I move tempdb off of the master device? 1.1.4 How do I correct timeslice -201? 1.1.5 The how's and why's on becoming Certified. 1.1.6 RAID and Sybase 1.1.7 How to swap a db device with another 1.1.8 Server naming and renaming 1.1.9 How do I interpret the tli strings in the interface file? 1.1.10 How can I tell the datetime my Server started? 1.1.11 Raw partitions or regular files? 1.1.12 Is Sybase Y2K (Y2000) compliant? 1.1.13 How can I run the ASE upgrade manually? 1.1.14 We have lost the sa password, what can we do? 1.1.15 How do I set a password to be null? 1.1.16 Does Sybase support Row Level Locking? 1.1.17 What platforms does ASE run on? 1.1.18 How do I backup databases > 64G on ASE prior to 12.x? 1.2: User Database Administration 1.2.1 Changing varchar(m) to varchar(n) 1.2.2 Frequently asked questions on Table partitioning 1.2.3 How do I manually drop a table? 1.2.4 Why not create all my columns varchar(255)? 1.2.5 What's a good example of a transaction? 1.2.6 What's a natural key? 1.2.7 Making a Stored Procedure invisible 1.2.8 Saving space when inserting rows monotonically 1.2.9 How to compute database fragmentation 1.2.10 Tasks a DBA should do... 1.2.11 How to implement database security 1.2.12 How to shrink a database 1.2.13 How do I turn on auditing of all SQL text sent to the server 1.2.14 sp_helpdb/sp_helpsegment is returning negative numbers 1.3: Advanced ASE Administration 1.3.1 How do I clear a log suspend'd connection? 1.3.2 What's the best value for cschedspins? 1.3.3 What traceflags are available? 1.3.4 How do I use traceflags 5101 and 5102? 1.3.5 What is cmaxpktsz good for? 1.3.6 What do all the parameters of a buildmaster -d<device> -yall mean? 1.3.7 What is CIS and how do I use it? 1.3.8 If the master device is full how do I make the master database bigger? 1.3.9 How do I run multiple versions of Sybase on the same server? 1.3.10 How do I capture a process's SQL? 1.4: General Troubleshooting 1. How do I turn off marked suspect on my database? 2. On startup, the transaction log of a database has filled and recovery has suspended, what can I do? 3. Why do my page locks not get escalated to a table lock after 200 locks? 1.5: Performance and Tuning 1.5.1 What are the nitty gritty details on Performance and Tuning? 1.5.2 What is best way to use temp tables in an OLTP environment? 1.5.3 What's the difference between clustered and non-clustered indexes? 1.5.4 Optimistic versus pessimistic locking? 1.5.5 How do I force an index to be used? 1.5.6 Why place tempdb and log on low numbered devices? 1.5.7 Have I configured enough memory for ASE? 1.5.8 Why should I use stored procedures? 1.5.9 I don't understand showplan's output, please explain. 1.5.10 Poor man's sp_sysmon. 1.5.11 View MRU-LRU procedure cache chain. 1.5.12 Improving Text/Image Type Performance 1.6: Server Monitoring 1.6.1 What is Monitor Server and how do I configure it? 1.6.2 OK, that was easy, how do I configure a client? 2.1: Platform Specific Issues - Solaris 2.1.1 Should I run 32 or 64 bit ASE with Solaris? 2.1.2 What is Intimate Shared Memory or ISM? 2.2: Platform Specific Issues - NT/2000 2.2.1 How to Start ASE on Remote NT Servers 2.2.2 How to Configure More than 2G bytes of Memory for ASE on NT 2.2.3 Installation Issues 2.3: Platform Specific Issues - Linux 2.3.1 ASE on Linux FAQ 3: DBCC's 3.1 How do I set TS Role in order to run certain DBCCs...? 3.2 What are some of the hidden/trick DBCC commands? 3.3 Other sites with DBCC information. 3.4 Fixing a Munged Log Performing any of the above may corrupt your ASE installation. Please do not call Sybase Technical Support after screwing up ASE. Remember, always take a dump of the master database and any other databases that are to be affected. 4: isql 4.1 How do I hide my password using isql? 4.2 How do I remove row affected and/or dashes when using isql? 4.3 How do I pipe the output of one isql to another? 4.4 What alternatives to isql exist? 4.5 How can I make isql secure? 5: bcp 5.1 How do I bcp null dates? 5.2 Can I use a named pipe to bcp/dump data out or in? 5.3 How do I exclude a column? 6.1: SQL Fundamentals 6.1.1 Are there alternatives to row at a time processing? 6.1.2 When should I execute an sp_recompile? 6.1.3 What are the different types of locks and what do they mean? 6.1.4 What's the purpose of using holdlock? 6.1.5 What's the difference between an update in place versus a deferred update? - see Q1.5.9 6.1.6 How do I find the oldest open transaction? 6.1.7 How do I check if log truncation is blocked? 6.1.8 The timestamp datatype 6.1.9 Stored Procedure Recompilation and Reresolution 6.1.10 How do I manipulate binary columns? 6.1.11 How do I remove duplicate rows from a table? 6.2: SQL Advanced 6.2.1 How to emulate the Oracle decode function/crosstab 6.2.2 How to implement if-then-else within a select-clause. 6.2.3 deleted due to copyright hassles with the publisher 6.2.4 How to pad with leading zeros an int or smallint. 6.2.5 Divide by zero and nulls. 6.2.6 Convert months to financial months. 6.2.7 Hierarchy traversal - BOMs. 6.2.8 Is it possible to call a UNIX command from within a stored procedure or a trigger? 6.2.9 Information on Identities and Rolling your own Sequential Keys 6.2.10 How can I execute dynamic SQL with ASE 6.2.11 Is it possible to concatenate all the values from a column and return a single row? 6.2.12 Selecting rows N to M without Oracle's rownum? 6.2.13 How can I return number of rows that are returned from a grouped query without using a temporary table? 6.3: Useful SQL Tricks 6.3.1 How to feed the result set of one stored procedure into another. 6.3.2 Is it possible to do dynamic SQL before ASE 12? 7: Open Client 7.1 What is Open Client? 7.2 What is the difference between DB-lib and CT-lib? 7.3 What is this TDS protocol? 7.4 I have upgraded to MS SQL Server 7.0 and can no longer connect from Sybase's isql. 7.5 The Basics of Connecting to Sybase 7.6 Connecting to ASE using ODBC 7.7 Which version of Open Client works with which ASE? 7.8 How do I tell the version of Open Client I am running? 9: Freeware 9.0 Where is all the code and why does Section 9 suddenly load in a reasonable amount of time? Stored Procedures 9.1.1 sp_freedevice - lists device, size, used and free. 9.1.2 sp_dos - This procedure graphically displays the scope of a object 9.1.3 sp_whodo - augments sp_who by including additional columns: cpu, I/O... 9.1.4 sp__revroles - creates DDL to sp_role a mirror of your SQL Server 9.1.5 sp__rev_configure - creates DDL to sp_configure a mirror of your SQL Server 9.1.6 sp_servermap - overview of your SQL Server 9.1.7 sp__create_crosstab - simplify crosstable queries 9.1.8 sp_ddl_create_table - creates DDL for all user tables in the current database 9.1.9 sp_spaceused_table 9.1.10 SQL to determine the space used for an index. 9.1.11 sp_helpoptions - Shows what options are set for a database. 9.1.12 sp_days - returns days in current month. 9.1.13 sp__optdiag - optdiag from within isql 9.1.14 sp_desc - a simple list of a tables' columns 9.1.15 sp_lockconfig - Displays locking schemes for tables. Shell Scripts 9.2.1 SQL and sh(1)to dynamically generate a dump/load database command. 9.2.2 update statistics script Perl/Sybperl 9.3.1 SybPerl - Perl interface to Sybase. 9.3.2 dbschema.pl - Sybperl script to reverse engineer a database. 9.3.3 ddl_insert.pl - creates insert DDL for a table. 9.3.4 int.pl - converts 12: Miscellany 12.1 What can Sybase IQ do for me? 12.2 Net-review of Sybase books 12.3 email lists 12.4 Finding Information at Sybase ASA Adaptive Server Anywhere 0.0 Preamble 0.1 What is ASA? 0.2 On what platforms is ASA supported? 0.3 What applications is ASA good for? 0.4 When would I choose ASA over ASE? 0.5 Does ASA Support Replication? 0.6 What is ASA UltraLite? 0.7 Links for further information REP Introduction to Replication Server 1.1 Introduction 1.2 Replication Server Components 1.3 What is the Difference Between SQL Remote and Replication Server? Replication Server Administration 2.1 How can I improve throughput? 2.2 Where should I install replication server? 2.3 Using large raw partitions with Replication Server on Unix. 2.4 How to replicate col = col + 1 2.5 What is the difference between an LTMs an a RepAgent? 2.6 Which Should I choose, RepAgent or LTM? Replication Server Trouble Shooting 3.1 Why am I running out of locks on the replicate side? 3.2 Someone was playing with replication and now the transaction log on OLTP is filling. Additional Information/Links 4.1 Links 4.2 Newsgroups |
|
|||
|
Sybase FAQ: 3/19 - REP
Archive-name: databases/sybase-faq/part3
URL: http://www.isug.com/Sybase_FAQ Version: 1.7 Maintainer: David Owen Last-modified: 2003/03/02 Posting-Frequency: posted every 3rd month A how-to-find-the-FAQ article is posted on the intervening months. Sybase Frequently Asked Questions Sybase FAQ Home PageAdaptive Server Enterprise FAQAdaptive Server Anywhere FAQ Repserver FAQSearch the FAQ [bar] Sybase Replication Server 1. Introduction to Replication Server 2. Replication Server Administration 3. Troubleshooting Replication Server 4. Additional Information/Links Introduction to Replication Server 1.1 Introduction 1.2 Replication Server Components 1.3 What is the Difference Between SQL Remote and Replication Server? Thanks go to Manish I Shah for major help with this introduction. next prev ASE FAQ ------------------------------------------------------------------------------- 1.1 Introduction ------------------------------------------------------------------------------- What is Replication Server Replication Server moves transactions (insert, updates and deletes) at the table level from a source dataserver to one or more destination dataservers. The dataserver could be ASE or other major DBMS flavour (including DB2, Informix, Oracle). The source and destinations need not be of the same type. What can it do ? * Move data from one source to another. * Move only a subset of data from source to destination. So, you can subscribe to a subset of data, or a subset of the columns, in the source table, e.g. select * from clients where state = NY * Manipulation/transformation of data when moving from source to destination. E.g. it can map data from a data-type in DB2 to an equivalent in Sybase.* * Provide a warm-standby system. Can be incorporated with Open Switch to provide a fairly seamless fail-over environment. * Merge data from several source databases into one destination database (could be for a warehouse type environment for example). * Move data through a complicated network down to branch offices, say, only sending the relevant data to each branch. (* This is one of Sybase replication's real strengths, the ability to define function string classes which allow the conversion of statements from one SQL dialect to match the dialect of the destination machine. Ed) How soon does the data move The data moves asynchronously. The time it takes to reach the destination depends on the size of your transaction, level of activity in that particular database (a database as in Sybase systems), the length of the chain (one or more replication servers that the transaction has to pass through to reach the destination), the thickness of pipe (network), how busy your replication server is etc. Usually, on a LAN, for small transactions, this is about a second. Back to top ------------------------------------------------------------------------------- 1.2 Replication Server Components ------------------------------------------------------------------------------- Basic Primary Dataserver The source of data where client applications enter/delete and modify data. As mentioned before, this need not be ASE, it can be Microsoft SQL Server, Oracle, DB2, Informix. (I know that I should get a complete list.) Replication Agent/Log Transfer Manager Log Transfer Manager (LTM) is a separate program/process which reads transaction log from the source server and transfers them to the replication server for further processing. With ASE 11.5, this has become part of ASE and is now called the Replication Agent. However, you still need to use an LTM for non-ASE sources. I imagine there is a version of LTM for each kind of source (DB2, Informix, Oracle etc). When replication is active, you see one connection per each replicated database in the source dataserver (sp_who). Replication Server (s) The replication server is an Open Server/Open Client application. The server part receives transactions being sent by either the source ASE or the source LTM. The client part sends these transactions to the target server which could be another replication server or the final dataserver. As far as I know, the server does not include the client component of any of the other DBMSes out of the box. Replicate (target) Dataserver Server in which the final replication server (in the queue) will repeat the transaction done on the primary. You will see a connection, one for each target database, in the target dataserver when the replication server is actively transferring data (when idle, the replication server disconnects or fades out in replication terminology). Back to top ------------------------------------------------------------------------------- 1.3 What is the Difference Between Replication Server and SQL Remote? ------------------------------------------------------------------------------- Both SQL Remote and Replication Server perform replication. SQL Remote was originally part of the Adaptive Server Anywhere tool kit and is intended for intermittent replication. (The classic example is that of a salesman connecting on a daily basis to upload sales and download new prices and inventory.) Replication Server is intended for near real-time replication scenarios. Back to top ------------------------------------------------------------------------------- next prev ASE FAQ Replication Server Administration 2.1 How can I improve throughput? 2.2 Where should I install replication server? 2.3 Using large raw partitions with Replication Server on Unix. 2.4 How to replicate col = col + 1 2.5 What is the difference between an LTMs an a RepAgent? 2.6 Which Should I choose, RepAgent or LTM? next prev ASE FAQ ------------------------------------------------------------------------------- 2.1 How can I improve throughput? ------------------------------------------------------------------------------- Check the Obvious First, ensure that you are only replicating those parts of the system that need to be replicated. Some of this is obvious. Don't replicate any table that does not need to be replicated. Check that you are only replicating the columns you need. Replication is very sophisticated and will allow you to replicate both a subset of the columns as well as a subset of the rows. Replicate Minimum Columns Once the replication is set up and synchronised, it is only necessary to replicate those parts of the primary system that actually change. You are only replicating those rows and columns that need to be replicated, but you only need to replicate the actual changes. Check that each replication definition is defined using the clause: create replication definition rep_def_name with primary... .... replicate minimal columns Second Replication Server This might be appropriate in a simple environment on systems with spare cycles and limited space on the network. When Sybase replicates from a primary to a replicate using only one replication server the data is transferred across the network uncompressed. However, the communication between two replication servers is compressed. By installing a second replication server it is possible to dramatically reduce the bandwidth needed to replicate your data. Dedicated Network Card Obviously, if replication is sharing the same network resources that all of the clients are using, there is the possibility for a bottleneck if the network bandwidth is close to saturation. If a second replication server is not going to cut it since you already have one or there are no spare cycles, then a second network card may be the answer. First, you will need to configure ASE to listen on two network connections. This is relatively straightforward. There is no change to the client configuration. They all continue to talk to Sybase using the same connection. When defining the replication server, ensure that the interfaces/sql.ini entry that it uses only has the second connection in it. This may involve some jiggery pokery with environment variables, but should be possible, even on NT! You need to be a little careful with network configuration. Sybase will communicate with the two servers on the correct address, but if the underlying operating system believes that both clients and repserver can be serviced by the same card, then it will use the first card that it comes to. So, if you had the situation that all of the clients, ASE and the replication server were on 192.168.1.0, and the host running ASE had two cards onto this same segment, then it would choose to route all packets through the first card. OK, so this is a very simplistic error to correct, but similar things can happen with more convoluted and, superficially, better thought out configurations. +---------+ +-----------+ +-----------+ | |--> NE(1) --> All Clients... | | | | | Primary | | repserver | | replicate | | |--> NE(2) --------------------->| |-->| | | | | | | | +---------+ +-----------+ +-----------+ So, configure NE(1) to be on 192.168.1.0, say, and NE(2) to be on 192.168.2.0 and all should be well. OK, so my character art is not perfect, but I think that you get the gist! No Network Card If RepServer resides on the same physical machine as either the primary or the replicate, it is possible to use the localhost or loopback network device. The loopback device is a network interface that connects back to itself without going through the network interface card. It is almost always uses the IP address 127.0.0.1. So, by applying the technique described above, but instead of using a dedicated network card, you use the loopback device. Obviously, the two servers have to be on the same physical machine or it won't work! Back to top ------------------------------------------------------------------------------- 2.2 Where should I install replication server? ------------------------------------------------------------------------------- A seemingly trivial question, but one that can cause novices a bit of worry. There are three answers: on the primary machine, on the replicate machine or on a completely separate machine. There is no right answer, and if you are doing an initial install it probably pays to consider the future, consider the proposed configuration and have a look at the load on the available machines. It is probably fair to say that replication is not power hungry but neither is it free. If the primary is only just about coping with its current load, then it might be as well looking into hosting it on another machine. The argument applies to the replicate. If you think that network bandwidth may be an issue, and you may have to add a second replication server, you may be better off starting with repserver running on the primary. It is marginally easier to add a repserver to an existing configuration if the first repserver is on the primary. Remember that a production replication server on Unix will require raw devices for the stable devices and that these can be more than 2GB in size. If you are restricted in the number of raw partitions you have available on a particular machine, then this may have a bearing. See Q2.3. Installing replication server on its own machine will, of course, introduce all sorts of problems of its own, as well as answering some. The load on the primary or the replicate is reduced considerably, but you are definitely going to add some load to the network. Remember that ASE->Rep and Rep->ASE is uncompressed. It is only Rep->Rep that is compressed. Back to top ------------------------------------------------------------------------------- 2.3 Using large raw partitions with Replication Server on Unix. ------------------------------------------------------------------------------- It is a good practice with production installations of Replication Server on Unix that you use raw partitions for the stable devices. This is for just the same reason that production ASE's use raw partitions. Raw devices can be a maximum of 2GB with replication server up to release 11.5. (I have not checked 12.) In order to utilise a raw partition that is greater than 2GB in size you can do the following (remember all of the cautionary warnings about trying this sort of stuff out in development first!): add partition firstpartition on '/dev/rdsk/c0t0d0s0' with size 2024 go add partition secondpartition on '/dev/rdsk/c0t0d0s0' with size 2024 starting at 2048 go Notice that the initial partition is sized at 2024MB and not 2048. I have not found this in the documentation, but replication certainly seems to have a problem allocating a full 2GB. Interestingly, do the same operation through Rep Server Manager and Sybase central caused no problems at all. Back to top ------------------------------------------------------------------------------- 2.4 How to replicate col = col + 1 ------------------------------------------------------------------------------- Firstly. While the rule that you never update a primary key may be a philosophical choice in a non-replicated system, it is an architectural requirement of a replicated system. If you use simple data replication, and your primary table is: id --- 1 2 3 and you issue a: update table set id=id+1 Rep server will do this in the replicate: begin tran update table set id=2 where id=1 update table set id=3 where id=2 update table set id=4 where id=3 commit tran Hands up all who can see a bit of a problem with this! Remember, repserver doesn't replicate statements, it replicates the results of statements. One way to perform this update is to build a stored procedure on both sides that executes the necessary update and replicate the stored procedure call. Back to top ------------------------------------------------------------------------------- 2.5 What is the difference between an LTM and a RepAgent? ------------------------------------------------------------------------------- As described in Section 1.2, Log Transfer Managers (LTMs) and RepAgents are the processes that transfer data between ASE and the Replication Server. LTMs were delivered with the first releases of Replication Server. Each LTM is a separate process at the operating system level that runs along side ASE and Replication Server. As with ASE and Replication Server, a RUN_<ltm_server> and configuration file is required for each LTM. One LTM is required for each database being replicated. Along with ASE 11.5 a new concept was introduced, that of RepAgent. I am not sure if you needed to use RepServer 11.5 as well, or whether the RepAgents could talk to earlier versions of Replication Server. Each RepAgent is, in effect, a slot-in replacement for an LTM. However, instead of running as separate operating system process, it runs as a thread within ASE. Pretty much all of the requirements for replication using an LTM apply to the RepAgents. One per database being replicated, etc. but now you do not need to have separate configuration files. Back to top ------------------------------------------------------------------------------- 2.6 Which should I use, RepAgent or LTM? ------------------------------------------------------------------------------- The differences between RepAgents and LTMs are discussed in Section 2.5. Which then to choose. There are pros and cons to both, however, I think that it should be stated up front that RepAgents are the latest offering and I believe that Sybase would expect you you to use that. Certainly the documentation for LTMs is a little buried implying that they do not consider it to be as current as LTMs. LTM Cons: * Older technology. Not sure if it is being actively supported. * Not integrated within ASE, so there is a (small) performance penalty. * Separate processes, so need additional monitoring in production environments. LTM Pros: * Possible to restart LTM without having to restart ASE. RepAgent Cons * If it crashes it is possible that you will have to restart ASE in order to restart RepAgent. RepAgent Pros * Latest, and presumably greatest, offering. * Tightly integrated with ASE so good performance. * Less to manage, no extra entries in the interfaces file. Back to top ------------------------------------------------------------------------------- next prev ASE FAQ Replication Server Trouble Shooting 3.1 Why am I running out of locks on the replicate side? 3.2 Someone was playing with replication and now the transaction log on OLTP is filling. next prev ASE FAQ ------------------------------------------------------------------------------- 3.1 Why am I running out of locks on the replicate side? ------------------------------------------------------------------------------- Sybase replication works by taking each transaction that occurs in the primary dataserver and applying to the replicate. Since replication works on the transaction log, a single, atomic, update on the primary side that updates a million rows will be translated into a million single row updates. This may seem very strange but is a simple consequence of how it works. On the primary, this million row update will attempt to escalate the locks that it has taken out to an exclusive table lock. However, on the replicate side each row is updated individually, much as if they were being updated within a cursor loop. Now, Sybase only tries to escalate locks from a single atomic statement (see ASE Qx.y), so it will never try to escalate the lock. However, since the updates are taking place within a single transaction, Sybase will need to take out enough page locks to lock the million rows. So, how much should you increase the locks parameter on the replicate side? A good rule of thumb might be double it or add 40,000 whichever is the larger. This has certainly worked for us. Back to top ------------------------------------------------------------------------------- 3.2 Someone was playing with replication and now the transaction log on OLTP is filling. ------------------------------------------------------------------------------- Once replication has been configured, ASE adds another marker to the transaction log. The first marker is the conventional one that marks which transactions have had their data written to disk. The second is there to ensure that the transactions have also been replicated. Clearly, if someone installed replication and did not clean up properly after themselves, this marker will still be there and consequently the transaction log will be filling up. If you are certain that replication is not being used on your system, you can disable the secondary truncation marker with the following commands: 1> use <database> 2> go 1> dbcc settrunc(ltm, ignore) 2> go The above code is the normal mechanism for disabling the trucation point. I have never had a problem with it. However, an alternative mechanism for disabling the truncation point is given below. I do not know if it will work in situations that the previous example won't, or if it works for databases that are damaged or what. If someone knows when you use it and why, please let me know (mailto:dowen@midsomer.org). 1> sp_role "grant", sybase_ts_role, sa 2> go 1> set role sybase_ts_role on 2> go 1> dbcc dbrepair(dbname, ltmignore) 2> go 1> sp_role "revoke", sybase_ts_role, sa 2> go This scenario is also very common if you load a copy of your replicated production database into development. Back to top ------------------------------------------------------------------------------- next prev ASE FAQ Additional Information/Links 4.1 Links 4.2 Newsgroups next prev ASE FAQ ------------------------------------------------------------------------------- 4.1 Links ------------------------------------------------------------------------------- Thierry Antinolfi has a replication FAQ at his site http://pro.wanadoo.fr/ dbadevil that covers a lot of good stuff. Rob Verschoor has a 'Replication Server Tips & Tricks' section on his site, as well as an indispensible quick reference guide! Back to top ------------------------------------------------------------------------------- 4.2 Newsgroups ------------------------------------------------------------------------------- There are a number of newsgroups that can deal with questions. Sybase have several in their own forums area. For Replication Server: sybase.public.rep-server sybase.public.rep-agent for SQL Remote and the issues of replicating with ASA: sybase.public.sqlanywhere.replication and of course, there is always the ubiquitous comp.databases.sybase. Back to top ------------------------------------------------------------------------------- next prev ASE FAQ |
|
|||
|
Sybase FAQ: 8/19 - ASE Admin (5 of 7)
Archive-name: databases/sybase-faq/part8
URL: http://www.isug.com/Sybase_FAQ Version: 1.7 Maintainer: David Owen Last-modified: 2003/03/02 Posting-Frequency: posted every 3rd month A how-to-find-the-FAQ article is posted on the intervening months. Performance and Tuning 1.5.1 What are the nitty gritty details on Performance and Tuning? 1.5.2 What is best way to use temp tables in an OLTP environment? 1.5.3 What's the difference between clustered and non-clustered indexes? 1.5.4 Optimistic versus pessimistic locking? 1.5.5 How do I force an index to be used? 1.5.6 Why place tempdb and log on low numbered devices? 1.5.7 Have I configured enough memory for ASE? 1.5.8 Why should I use stored procedures? 1.5.9 I don't understand showplan's output, please explain. 1.5.10 Poor man's sp_sysmon. 1.5.11 View MRU-LRU procedure cache chain. 1.5.12 Improving Text/Image Type Performance Server Monitoring General Troubleshooting ASE FAQ ------------------------------------------------------------------------------- 1.5.1: Sybase ASE Performance and Tuning ------------------------------------------------------------------------------- Before going any further, Eric Miner (eric.miner@sybase.com) has made available two presentations that he made at Techwave 1999. The first covers the use of optdiag. The second covers features in the way the optimiser works in ASE 11.9.2 and 12. These are Powerpoint slides converted to web pages, so they might be tricky to read with a text based browser! All Components Affect Response Time & Throughput We often think that high performance is defined as a fast data server, but the picture is not that simple. Performance is determined by all these factors: * The client application itself: + How efficiently is it written? + We will return to this later, when we look at application tuning. * The client-side library: + What facilities does it make available to the application? + How easy are they to use? * The network: + How efficiently is it used by the client/server connection? * The DBMS: + How effectively can it use the hardware? + What facilities does it supply to help build efficient fast applications? * The size of the database: + How long does it take to dump the database? + How long to recreate it after a media failure? Unlike some products which aim at performance on paper, Sybase aims at solving the multi-dimensional problem of delivering high performance for real applications. OBJECTIVES To gain an overview of important considerations and alternatives for the design, development, and implementation of high performance systems in the Sybase client/server environment. The issues we will address are: * Client Application and API Issues * Physical Database Design Issues * Networking Issues * Operating System Configuration Issues * Hardware Configuration Issues * ASE Configuration Issues Client Application and Physical Database Design design decisions will account for over 80% of your system's "tuneable" performance so ... plan your project resources accordingly ! It is highly recommended that every project include individuals who have taken Sybase Education's Performance and Tuning course. This 5-day course provides the hands-on experience essential for success. Client Application Issues * Tuning Transact-SQL Queries * Locking and Concurrency * ANSI Changes Affecting Concurrency * Application Deadlocking * Optimizing Cursors in v10 * Special Issues for Batch Applications * Asynchronous Queries * Generating Sequential Numbers * Other Application Issues Tuning Transact-SQL Queries * Learn the Strengths and Weaknesses of the Optimizer * One of the largest factors determining performance is TSQL! Test not only for efficient plans but also semantic correctness. * Optimizer will cost every permutation of accesses for queries involving 4 tables or less. Joins of more than 4 tables are "planned" 4-tables at a time (as listed in the FROM clause) so not all permutations are evaluated. You can influence the plans for these large joins by the order of tables in the FROM clause. * Avoid the following, if possible: + What are SARGS? This is short for search arguments. A search argument is essentially a constant value such as: o "My company name" o 3448 but not: o 344 + 88 o like "%what you want%" + Mathematical Manipulation of SARGs SELECT name FROM employee WHERE salary * 12 > 100000 + Use of Incompatible Datatypes Between Column and its SARG Float & Int, Char & Varchar, Binary & Varbinary are Incompatible; Int & Intn (allow nulls) OK + Use of multiple "OR" Statements - especially on different columns in same table. If any portion of the OR clause requires a table scan, it will! OR Strategy requires additional cost of creating and sorting a work table. + Not using the leading portion of the index (unless the query is completely covered) + Substituting "OR" with "IN (value1, value2, ... valueN) Optimizer automatically converts this to an "OR" + Use of Non-Equal Expressions (!=) in WHERE Clause. * Use Tools to Evaluate and Tune Important/Problem Queries + Use the "set showplan on" command to see the plan chosen as "most efficient" by optimizer. Run all queries through during development and testing to ensure accurate access model and known performance. Information comes through the Error Handler of a DB-Library application. + Use the "dbcc traceon(3604, 302, 310)" command to see each alternative plan evaluated by the optimizer. Generally, this is only necessary to understand why the optimizer won't give you the plan you want or need (or think you need)! + Use the "set statistics io on" command to see the number of logical and physical i/o's for a query. Scrutinize those queries with high logical i/o's. + Use the "set statistics time on" command to see the amount of time (elapsed, execution, parse and compile) a query takes to run. + If the optimizer turns out to be a "pessimizer", use the "set forceplan on" command to change join order to be the order of the tables in the FROM clause. + If the optimizer refuses to select the proper index for a table, you can force it by adding the index id in parentheses after the table name in the FROM clause. SELECT * FROM orders(2), order_detail(1) WHERE ... This may cause portability issues should index id's vary/change by site ! Locking and Concurrency * The Optimizer Decides on Lock Type and Granularity * Decisions on lock type (share, exclusive, or update) and granularity (page or table) are made during optimization so make sure your updates and deletes don't scan the table ! * Exclusive Locks are Only Released Upon Commit or Rollback * Lock Contention can have a large impact on both throughput and response time if not considered both in the application and database design ! * Keep transactions as small and short as possible to minimize blocking. Consider alternatives to "mass" updates and deletes such as a v10.0 cursor in a stored procedure which frequently commits. * Never include any "user interaction" in the middle of transactions. * Shared Locks Generally Released After Page is Read * Share locks "roll" through result set for concurrency. Only "HOLDLOCK" or "Isolation Level 3" retain share locks until commit or rollback. Remember also that HOLDLOCK is for read-consistency. It doesn't block other readers ! * Use optimistic locking techniques such as timestamps and the tsequal() function to check for updates to a row since it was read (rather than holdlock) ANSI Changes Affecting Concurrency * Chained Transactions Risk Concurrency if Behavior not Understood * Sybase defaults each DML statement to its own transaction if not specified ; * ANSI automatically begins a transaction with any SELECT, FETCH, OPEN, INSERT, UPDATE, or DELETE statement ; * If Chained Transaction must be used, extreme care must be taken to ensure locks aren't left held by applications unaware they are within a transaction! This is especially crucial if running at Level 3 Isolation * Lock at the Level of Isolation Required by the Query * Read Consistency is NOT a requirement of every query. * Choose level 3 only when the business model requires it * Running at Level 1 but selectively applying HOLDLOCKs as needed is safest * If you must run at Level 3, use the NOHOLDLOCK clause when you can ! * Beware of (and test) ANSI-compliant third-party applications for concurrency Application Deadlocking Prior to ASE 10 cursors, many developers simulated cursors by using two or more connections (dbproc's) and divided the processing between them. Often, this meant one connection had a SELECT open while "positioned" UPDATEs and DELETEs were issued on the other connection. The approach inevitably leads to the following problem: 1. Connection A holds a share lock on page X (remember "Rows Pending" on SQL Server leave a share lock on the "current" page). 2. Connection B requests an exclusive lock on the same page X and waits... 3. The APPLICATION waits for connection B to succeed before invoking whatever logic will remove the share lock (perhaps dbnextrow). Of course, that never happens ... Since Connection A never requests a lock which Connection B holds, this is NOT a true server-side deadlock. It's really an "application" deadlock ! Design Alternatives 1. Buffer additional rows in the client that are "nonupdateable". This forces the shared lock onto a page on which the application will not request an exclusive lock. 2. Re-code these modules with CT-Library cursors (aka. server-side cursors). These cursors avoid this problem by disassociating command structures from connection structures. 3. Re-code these modules with DB-Library cursors (aka. client-side cursors). These cursors avoid this problem through buffering techniques and re-issuing of SELECTs. Because of the re-issuing of SELECTs, these cursors are not recommended for high transaction sites ! Optimizing Cursors with v10.0 * Always Declare Cursor's Intent (i.e. Read Only or Updateable) * Allows for greater control over concurrency implications * If not specified, ASE will decide for you and usually choose updateable * Updateable cursors use UPDATE locks preventing other U or X locks * Updateable cursors that include indexed columns in the update list may table scan * SET Number of Rows for each FETCH * Allows for greater Network Optimization over ANSI's 1- row fetch * Rows fetched via Open Client cursors are transparently buffered in the client: FETCH -> Open Client <- N rows Buffers * Keep Cursor Open on a Commit / Rollback * ANSI closes cursors with each COMMIT causing either poor throughput (by making the server re-materialize the result set) or poor concurrency (by holding locks) * Open Multiple Cursors on a Single Connection * Reduces resource consumption on both client and Server * Eliminates risk of a client-side deadlocks with itself Special Issues for Batch Applications ASE was not designed as a batch subsystem! It was designed as an RBDMS for large multi-user applications. Designers of batch-oriented applications should consider the following design alternatives to maximize performance : Design Alternatives : * Minimize Client/Server Interaction Whenever Possible * Don't turn ASE into a "file system" by issuing single table / single row requests when, in actuality, set logic applies. * Maximize TDS packet size for efficient Interprocess Communication (v10 only) * New ASE 10.0 cursors declared and processed entirely within stored procedures and triggers offer significant performance gains in batch processing. * Investigate Opportunities to Parallelize Processing * Breaking up single processes into multiple, concurrently executing, connections (where possible) will outperform single streamed processes everytime. * Make Use of TEMPDB for Intermediate Storage of Useful Data Asynchronous Queries Many, if not most, applications and 3rd Party tools are coded to send queries with the DB-Library call dbsqlexec( ) which is a synchronous call ! It sends a query and then waits for a response from ASE that the query has completed ! Designing your applications for asynchronous queries provides many benefits: 1. A "Cooperative" multi-tasking application design under Windows will allow users to run other Windows applications while your long queries are processed ! 2. Provides design opportunities to parallize work across multiple ASE connections. Implementation Choices: * System 10 Client Library Applications: * True asynchronous behaviour is built into the entire library. Through the appropriate use of call-backs, asynchronous behavior is the normal processing paradigm. * Windows DB-Library Applications (not true async but polling for data): * Use dbsqlsend(), dbsqlok(), and dbdataready() in conjunction with some additional code in WinMain() to pass control to a background process. Code samples which outline two different Windows programming approaches (a PeekMessage loop and a Windows Timer approach) are available in the Microsoft Software Library on Compuserve (GO MSL). Look for SQLBKGD.ZIP * Non-PC DB-Library Applications (not true async but polling for data): * Use dbsqlsend(), dbsqlok(), and dbpoll() to utilize non-blocking functions. Generating Sequential Numbers Many applications use unique sequentially increasing numbers, often as primary keys. While there are good benefits to this approach, generating these keys can be a serious contention point if not careful. For a complete discussion of the alternatives, download Malcolm Colton's White Paper on Sequential Keys from the SQL Server Library of our OpenLine forum on Compuserve. The two best alternatives are outlined below. 1. "Primary Key" Table Storing Last Key Assigned + Minimize contention by either using a seperate "PK" table for each user table or padding out each row to a page. Make sure updates are "in-place". + Don't include the "PK" table's update in the same transaction as the INSERT. It will serialize the transactions. BEGIN TRAN UPDATE pk_table SET nextkey = nextkey + 1 [WHERE table_name = @tbl_name] COMMIT TRAN /* Now retrieve the information */ SELECT nextkey FROM pk_table WHERE table_name = @tbl_name] + "Gap-less" sequences require additional logic to store and retrieve rejected values 2. IDENTITY Columns (v10.0 only) + Last key assigned for each table is stored in memory and automatically included in all INSERTs (BCP too). This should be the method of choice for performance. + Choose a large enough numeric or else all inserts will stop once the max is hit. + Potential rollbacks in long transactions may cause gaps in the sequence ! Other Application Issues + Transaction Logging Can Bottleneck Some High Transaction Environments + Committing a Transaction Must Initiate a Physical Write for Recoverability + Implementing multiple statements as a transaction can assist in these environment by minimizing the number of log writes (log is flushed to disk on commits). + Utilizing the Client Machine's Processing Power Balances Load + Client/Server doesn't dictate that everything be done on Server! + Consider moving "presentation" related tasks such as string or mathematical manipulations, sorting, or, in some cases, even aggregating to the client. + Populating of "Temporary" Tables Should Use "SELECT INTO" - balance this with dynamic creation of temporary tables in an OLTP environment. Dynamic creation may cause blocks in your tempdb. + "SELECT INTO" operations are not logged and thus are significantly faster than there INSERT with a nested SELECT counterparts. + Consider Porting Applications to Client Library Over Time + True Asynchronous Behavior Throughout Library + Array Binding for SELECTs + Dynamic SQL + Support for ClientLib-initiated callback functions + Support for Server-side Cursors + Shared Structures with Server Library (Open Server 10) Physical Database Design Issues + Normalized -vs- Denormalized Design + Index Selection + Promote "Updates-in-Place" Design + Promote Parallel I/O Opportunities Normalized -vs- Denormalized + Always Start with a Completely Normalized Database + Denormalization should be an optimization taken as a result of a performance problem + Benefits of a normalized database include : 1. Accelerates searching, sorting, and index creation since tables are narrower 2. Allows more clustered indexes and hence more flexibility in tuning queries, since there are more tables ; 3. Accelerates index searching since indexes tend to be narrower and perhaps shorter ; 4. Allows better use of segments to control physical placement of tables ; 5. Fewer indexes per table, helping UPDATE, INSERT, and DELETE performance ; 6. Fewer NULLs and less redundant data, increasing compactness of the database ; 7. Accelerates trigger execution by minimizing the extra integrity work of maintaining redundant data. 8. Joins are Generally Very Fast Provided Proper Indexes are Available 9. Normal caching and cindextrips parameter (discussed in Server section) means each join will do on average only 1-2 physical I/Os. 10. Cost of a logical I/O (get page from cache) only 1-2 milliseconds. 3. There Are Some Good Reasons to Denormalize 1. All queries require access to the "full" set of joined data. 2. Majority of applications scan entire tables doing joins. 3. Computational complexity of derived columns require storage for SELECTs 4. Others ... Index Selection + Without a clustered index, all INSERTs and "out-of-place" UPDATEs go to the last page. The lock contention in high transaction environments would be prohibitive. This is also true for INSERTs to a clustered index on a monotonically increasing key. + High INSERT environments should always cluster on a key which provides the most "randomness" (to minimize lock / device contention) that is usable in many queries. Note this is generally not your primary key ! + Prime candidates for clustered index (in addition to the above) include : o Columns Accessed by a Range o Columns Used with Order By, Group By, or Joins + Indexes Help SELECTs and Hurt INSERTs + Too many indexes can significantly hurt performance of INSERTs and "out-of-place" UPDATEs. + Prime candidates for nonclustered indexes include : o Columns Used in Queries Requiring Index Coverage o Columns Used to Access Less than 20% (rule of thumb) of the Data. + Unique indexes should be defined as UNIQUE to help the optimizer + Minimize index page splits with Fillfactor (helps concurrency and minimizes deadlocks) + Keep the Size of the Key as Small as Possible + Accelerates index scans and tree traversals + Use small datatypes whenever possible . Numerics should also be used whenever possible as they compare faster than strings. Promote "Update-in-Place" Design + "Update-in-Place" Faster by Orders of Magnitude + Performance gain dependent on number of indexes. Recent benchmark (160 byte rows, 1 clustered index and 2 nonclustered) showed 800% difference! + Alternative ("Out-of-Place" Update) implemented as a physical DELETE followed by a physical INSERT. These tactics result in: 1. Increased Lock Contention 2. Increased Chance of Deadlock 3. Decreased Response Time and Throughput + Currently (System 10 and below), Rules for "Update-in-Place" Behavior Include : 1. Columns updated can not be variable length or allow nulls 2. Columns updated can not be part of an index used to locate the row to update 3. No update trigger on table being updated (because the inserted and deleted tables used in triggers get their data from the log) In v4.9.x and below, only one row may be affected and the optimizer must know this in advance by choosing a UNIQUE index. System 10 eliminated this limitation. Promote Parallel I/O Opportunities + For I/O-bound Multi-User Systems, Use A lot of Logical and Physical Devices + Plan balanced separation of objects across logical and physical devices. + Increased number of physical devices (including controllers) ensures physical bandwidth + Increased number of logical Sybase devices ensures minimal contention for internal resources. Look at SQL Monitor's Device I/O Hit Rate for clues. Also watch out for the 128 device limit per database. + Create Database (in v10) starts parallel I/O on up to 6 devices at a time concurrently. If taken advantage of, expect an 800% performance gain. A 2Gb TPC-B database that took 4.5 hours under 4.9.1 to create now takes 26 minutes if created on 6 independent devices ! + Use Sybase Segments to Ensure Control of Placement This is the only way to guarantee logical seperation of objects on devices to reduce contention for internal resources. + Dedicate a seperate physical device and controller to the transaction log in tempdb too. + optimize TEMPDB Also if Heavily Accessed + increased number of logical Sybase devices ensures minimal contention for internal resources. + systems requiring increased log throughput today must partition database into separate databases Breaking up one logical database into multiple smaller databases increases the number number of transaction logs working in parallel. Networking Issues + Choice of Transport Stacks + Variable Sized TDS Packets + TCP/IP Packet Batching Choice of Transport Stacks for PCs + Choose a Stack that Supports "Attention Signals" (aka. "Out of Band Data") + Provides for the most efficient mechanism to cancel queries. + Essential for sites providing ad-hoc query access to large databases. + Without "Attention Signal" capabilities (or the urgent flag in the connection string), the DB-Library functions DBCANQUERY ( ) and DBCANCEL ( ) will cause ASE to send all rows back to the Client DB-Library as quickly as possible so as to complete the query. This can be very expensive if the result set is large and, from the user's perspective, causes the application to appear as though it has hung. + With "Attention Signal" capabilities, Net-Library is able to send an out-of-sequence packet requesting the ASE to physically throw away any remaining results providing for instantaneous response. + Currently, the following network vendors and associated protocols support the an "Attention Signal" capable implementation: 1. NetManage NEWT 2. FTP TCP 3. Named Pipes (10860) - Do not use urgent parameter with this Netlib 4. Novell LAN Workplace v4.1 0 Patch required from Novell 5. Novell SPX - Implemented internally through an "In-Band" packet 6. Wollongong Pathway 7. Microsoft TCP - Patch required from Microsoft Variable-sized TDS Packets Pre-v4.6 TDS Does Not Optimize Network Performance Current ASE TDS packet size limited to 512 bytes while network frame sizes are significantly larger (1508 bytes on Ethernet and 4120 bytes on Token Ring). The specific protocol may have other limitations! For example: + IPX is limited to 576 bytes in a routed network. + SPX requires acknowledgement of every packet before it will send another. A recent benchmark measured a 300% performance hit over TCP in "large" data transfers (small transfers showed no difference). + Open Client Apps can "Request" a Larger Packet Shown to have significant performance improvement on "large" data transfers such as BCP, Text / Image Handling, and Large Result Sets. o clients: # isql -Usa -Annnnn # bcp -Usa -Annnnn # ct_con_props (connection, CS_SET, CS_PACKETSIZE, &packetsize, sizeof(packetsize), NULL) o An "SA" must Configure each Servers' Defaults Properly # sp_configure "default packet size", nnnnn - Sets default packet size per client connection (defaults to 512) # sp_configure "maximum packet size", nnnnn - Sets maximum TDS packet size per client connection (defaults to 512) # sp_configure "additional netmem", nnnnn - Additional memory for large packets taken from separate pool. This memory does not come from the sp_configure memory setting. Optimal value = ((# connections using large packets large packetsize * 3) + an additional 1-2% of the above calculation for overhead) Each connection using large packets has 3 network buffers: one to read; one to write; and one overflow. @ Default network memory - Default-sized packets come from this memory pool. @ Additional Network memory - Big packets come this memory pool. If not enough memory is available in this pool, the server will give a smaller packet size, down to the default TCP/IP Packet Batching + TCP Networking Layer Defaults to "Packet Batching" + This means that TCP/IP will batch small logical packets into one larger physical packet by briefly delaying packets in an effort to fill the physical network frames (Ethernet, Token-Ring) with as much data as possible. + Designed to improve performance in terminal emulation environments where there are mostly only keystrokes being sent across the network. + Some Environments Benefit from Disabling Packet Batching + Applies mainly to socket-based networks (BSD) although we have seen some TLI networks such as NCR's benefit. + Applications sending very small result sets or statuses from sprocs will usually benefit. Benchmark with your own application to be sure. + This makes ASE open all connections with the TCP_NODELAY option. Packets will be sent regardless of size. + To disable packet batching, in pre-Sys 11, start ASE with the 1610 Trace Flag. $SYBASE/dataserver -T1610 -d /usr/u/sybase/master.dat ... Your errorlog will indicate the use of this option with the message: ASE booted with TCP_NODELAY enabled. Operating System Issues + Never Let ASE Page Fault + It is better to configure ASE with less memory and do more physical database I/O than to page fault. OS page faults are synchronous and stop the entire dataserver engine until the page fault completes. Since database I/O's are asynchronous, other user tasks can continue! + Use Process Affinitying in SMP Environments, if Supported + Affinitying dataserver engines to specific CPUs minimizes overhead associated with moving process information (registers, etc) between CPUs. Most implementations will preference other tasks onto other CPUs as well allowing even more CPU time for dataserver engines. + Watch out for OS's which are not fully symmetric. Affinitying dataserver engines onto CPUs that are heavily used by the OS can seriously degrade performance. Benchmark with your application to find optimal binding. + Increase priority of dataserver engines, if supported + Give ASE the opportunity to do more work. If ASE has nothing to do, it will voluntarily yield the CPU. + Watch out for OS's which externalize their async drivers. They need to run too! + Use of OS Monitors to Verify Resource Usage + The OS CPU monitors only "know" that an instruction is being executed. With ASE's own threading and scheduling, it can routinely be 90% idle when the OS thinks its 90% busy. SQL Monitor shows real CPU usage. + Look into high disk I/O wait time or I/O queue lengths. These indicate physical saturation points in the I/O subsystem or poor data distribution. + Disk Utilization above 50% may be subject to queuing effects which often manifest themselves as uneven response times. + Look into high system call counts which may be symptomatic of problems. + Look into high context switch counts which may also be symptomatic of problems. + Optimize your kernel for ASE (minimal OS file buffering, adequate network buffers, appropriate KEEPALIVE values, etc). + Use OS Monitors and SQL Monitor to Determine Bottlenecks + Most likely "Non-Application" contention points include: Resource Where to Look --------- -------------- CPU Performance SQL Monitor - CPU and Trends Physical I/O Subsystem OS Monitoring tools - iostat, sar... Transaction Log SQL Monitor - Device I/O and Device Hit Rate on Log Device ASE Network Polling SQL Monitor - Network and Benchmark Baselines Memory SQL Monitor - Data and Cache Utilization + Use of Vendor-support Striping such as LVM and RAID + These technologies provide a very simple and effective mechanism of load balancing I/O across physical devices and channels. + Use them provided they support asynchronous I/O and reliable writes. + These approaches do not eliminate the need for Sybase segments to ensure minimal contention for internal resources. + Non-read-only environments should expect performance degradations when using RAID levels other than level 0. These levels all include fault tolerance where each write requires additional reads to calculate a "parity" as well as the extra write of the parity data. Hardware Configuration Issues + Number of CPUs + Use information from SQL Monitor to assess ASE's CPU usage. + In SMP environments, dedicate at least one CPU for the OS. + Advantages and scaling of VSA is application-dependent. VSA was architected with large multi-user systems in mind. + I/O Subsystem Configuration + Look into high Disk I/O Wait Times or I/O Queue Lengths. These may indicate physical I/O saturation points or poor data distribution. + Disk Utilization above 50% may be subject to queuing effects which often manifest themselves as uneven response times. + Logical Volume configurations can impact performance of operations such as create database, create index, and bcp. To optimize for these operations, create Logical Volumes such that they start on different channels / disks to ensure I/O is spread across channels. + Discuss device and controller throughput with hardware vendors to ensure channel throughput high enough to drive all devices at maximum rating. General ASE Tuning + Changing Values with sp_configure or buildmaster It is imperative that you only use sp_configure to change those parameters that it currently maintains because the process of reconfiguring actually recalculates a number of other buildmaster parameters. Using the Buildmaster utility to change a parameter "managed" by sp_configure may result in a mis-configured server and cause adverse performance or even worse ... + Sizing Procedure Cache o ASE maintains an MRU-LRU chain of stored procedure query plans. As users execute sprocs, ASE looks in cache for a query plan to use. However, stored procedure query plans are currently not re-entrant! If a query plan is available, it is placed on the MRU and execution begins. If no plan is in memory, or if all copies are in use, a new copy is read from the sysprocedures table. It is then optimized and put on the MRU for execution. o Use dbcc memusage to evaluate the size and number of each sproc currently in cache. Use SQL Monitor's cache statistics to get your average cache hit ratio. Ideally during production, one would hope to see a high hit ratio to minimize the procedure reads from disk. Use this information in conjuction with your desired hit ratio to calculate the amount of memory needed. + Memory o Tuning memory is more a price/performance issue than anything else ! The more memory you have available, the greater than probability of minimizing physical I/O. This is an important goal though. Not only does physical I/O take significantly longer, but threads doing physical I/O must go through the scheduler once the I/O completes. This means that work on behalf of the thread may not actually continue to execute for quite a while ! o There are no longer (as of v4.8) any inherent limitations in ASE which cause a point of diminishing returns on memory size. o Calculate Memory based on the following algorithm : Total Memory = Dataserver Executable Size (in bytes) + Static Overhead of 1 Mb + User Connections x 40,960 bytes + Open Databases x 644 bytes + Locks x 32 bytes + Devices x 45,056 bytes + Procedure Cache + Data Cache + Recovery Interval o As users change data in ASE, only the transaction log is written to disk right away for recoverability. "Dirty" data and index pages are kept in cache and written to disk at a later time. This provides two major benefits: 1. Many transactions may change a page yet only one physical write is done 2. ASE can schedule the physical writes "when appropriate" o ASE must eventually write these "dirty" pages to disk. o A checkpoint process wakes up periodically and "walks" the cache chain looking for dirty pages to write to disk o The recovery interval controls how often checkpoint writes dirty pages. + Tuning Recovery Interval o A low value may cause unnecessary physical I/O lowering throughput of the system. Automatic recovery is generally much faster during boot-up. o A high value minimizes unnecessary physical I/O and helps throughput of the system. Automatic recovery may take substantial time during boot-up. Audit Performance Tuning for v10.0 + Potentially as Write Intensive as Logging + Isolate Audit I/O from other components. + Since auditing nearly always involves sequential writes, RAID Level 0 disk striping or other byte-level striping technology should provide the best performance (theoretically). + Size Audit Queue Carefully + Audit records generated by clients are stored in an in memory audit queue until they can be processed. + Tune the queue's size with sp_configure "audit queue size", nnnn (in rows). + Sizing this queue too small will seriously impact performance since all user processes who generate audit activity will sleep if the queue fills up. + Size Audit Database Carefully + Each audit row could require up to 416 bytes depending on what is audited. + Sizing this database too small will seriously impact performance since all user processes who generate audit activity will sleep if the database fills up. Back to top ------------------------------------------------------------------------------- 1.5.2: Temp Tables and OLTP ------------------------------------------------------------------------------- (Note from Ed: It appears that with ASE 12, Sybase have solved the problem of select/into locking the system tables for the duration of the operation. The operation is now split into two parts, the creation of the table followed byt the insert. The system tables are only locked for the first part, and so, to all intents and purposes, the operation acts like a create/insert pair whilst remaining minimally logged. Our shop would like to inform folks of a potential problem when using temporary tables in an OLTP environment. Using temporary tables dynamically in a OLTP production environment may result in blocking (single-threading) as the number of transactions using the temporary tables increases. Does it affect my application? This warning only applies for SQL that is being invoked frequently in an OLTP production environment, where the use of "select into..." or "create table # temp" is common. Application using temp tables may experience blocking problems as the number of transactions increases. This warning does not apply to SQL that may be in a report or that is not used frequently. Frequently is defined as several times per second. Why? Why? Why? Our shop was working with an application owner to chase down a problem they were having during peak periods. The problem they were having was severe blocking in tempdb. What was witnessed by the DBA group was that as the number of transactions increased on this particular application, the number of blocks in tempdb also increased. We ran some independent tests to simulate a heavily loaded server and discovered that the data pages in contention were in tempdb's syscolumns table. This actually makes sense because during table creation entries are added to this table, regardless if it's a temporary or permanent table. We ran another simulation where we created the tables before the stored procedure used it and the blocks went away. We then performed an additional test to determine what impact creating temporary tables dynamically would have on the server and discovered that there is a 33% performance gain by creating the tables once rather than re-creating them. Your mileage may vary. How do I fix this? To make things better, do the 90's thing -- reduce and reuse your temp tables. During one application connection/session, aim to create the temp tables only once. Let's look at the lifespan of a temp table. If temp tables are created in a batch within a connection, then all future batches and stored procs will have access to such temp tables until they're dropped; this is the reduce and reuse strategy we recommend. However, if temp tables are created in a stored proc, then the database will drop the temp tables when the stored proc ends, and this means repeated and multiple temp table creations; you want to avoid this. Recode your stored procedures so that they assume that the temporary tables already exist, and then alter your application so that it creates the temporary tables at start-up -- once and not every time the stored procedure is invoked. That's it! Pretty simple eh? Summary The upshot is that you can realize roughly a 33% performance gain and not experience the blocking which is difficult to quantify due to the specificity of each application. Basically, you cannot lose. Solution in pseudo-code If you have an application that creates the same temp table many times within one connection, here's how to convert it to reduce and reuse temp table creations. Raymond Lew has supplied a detailed example for trying this. Old open connection loop until time to go exec procedure vavoom_often /* vavoom_often creates and uses #gocart for every call */ /* eg: select * into #gocart from gocart */ go |
![]() |
| Thread Tools | |
|
|