Wednesday, August 29, 2018

How Big is Big? (2018 Update - Db2 for z/OS Buffer Pools and DDF Activity)

Almost 5 years ago, I posted to this blog an entry on the question, "How big is big?" in a Db2 for z/OS context. Two areas that I covered in that blog entry are buffer pool configuration size and DDF transaction volume. Quite a lot has changed since October 2013, and it's time for a Db2 "How big is big?" update. In particular, I want to pass on some more-current information regarding buffer pool sizing and DDF activity.

How big is big? (buffer pools)

Back in 2013, when I posted the aforementioned blog entry, the largest buffer pool configuration I'd seen (i.e., the aggregate size of all buffer pools allocated for a single Db2 for z/OS subsystem) was 46 GB. That Db2 subsystem ran in a z/OS LPAR with 180 GB of real storage. Fast-forward to August 2018, and my, how z/OS LPAR memory resources - and exploitation of same via large buffer pools - have grown. The biggest buffer pool configuration for a single Db2 subsystem that I've seen to date? How about 879 GB, in a z/OS LPAR that has 1104 GB (almost 1.1 TB) of central storage. A single pool in that configuration has 66,500,000 buffers of 4 KB each - that's over 253 GB of space in one pool. Does that humongous amount of buffer pool space - over 600 GB of which is page-fixed in memory - put undue pressure on the z/OS LPAR's real storage? No. The demand paging rate for that system (a busy data server, processing about 14,000 SQL statements per second during peak times) is a big fat zero. That's because the 225 GB of memory not used for Db2 buffer pools is plenty for the other real storage requirements in the LPAR.

What does the organization with the great big Db2 buffer pool configuration get in return for using lots and lots of memory for data and index page caching? It gets tremendous suppression of disk subsystem read I/Os: I saw that for an hour during which the volume of data access activity on the system was really high, the highest total read I/O rate for any of the buffer pools was 48 per second (very low). During that peak-busy time, two of the other buffer pools had total read I/O rates of 15 and 13 per second (very, very low), five pools had total read I/O rates between 2 and 5 per second (super-low), and the other nine active pools had total read I/O rates of less than 1 per second, or even 0 (super-duper low). And what are the payoffs from tremendous suppression of disk read I/Os? CPU savings (every I/O - synch or asynch - consumes CPU time) and improved transaction and batch job elapsed times (in Db2 monitor accounting-long reports, wait time related to synchronous and asynchronous database reads - the latter is labeled "wait for other read" - becomes a very small percentage of in-Db2 elapsed time).

z/OS LPAR memory sizes are getting larger all the time. If you've got it, use it - and using it for big (maybe really, really big) buffer pools can be a great move on your part. In doing that, don't forget to leverage fixed-in-memory buffer pools, large page frames, and maybe "pinning" pools (the latter are used to cache associated database objects in memory in their entirety, and should be defined with PGSTEAL(NONE)).

How big is big? (DDF transaction volume)

In the above-cited "How big is big" blog entry, I noted that the highest DDF transaction rate I'd seen for a single Db2 subsystem (average over a 1-hour period) was 786 per second. A few months ago, I saw data from a Db2 subsystem that was processing 3057 DDF transactions per second (again, that's the average over a 1-hour period) - almost 4 times the highest DDF transaction rate I'd seen back in 2013. [It's easy to calculate a DDF transaction rate: in a Db2 monitor accounting-long report with data grouped by connection type, in the section on the DRDA connection type, divide the commit count by the number of seconds in the reporting interval, and there's your transaction rate.]

I have seen that an ever-growing percentage of overall Db2 for z/OS workloads - and a really big percentage of new Db2-accessing application workloads - involve Db2 access via the distributed data facility. This, combined with the increasing processing capacity delivered by new generations of IBM Z servers, plus DDF-related performance features such as high-performance DBATs and the SMT2 mode in which zIIP engines can operate, add up to substantial growth in DDF transaction volumes at many Db2 for z/OS sites (the organization with the DDF transaction rate in excess of 3000 per second for a Db2 subsystem runs the zIIP engines in the associated z/OS LPAR in SMT2 mode). DDF transaction rates are likely to get a further boost as companies take advantage of Db2's built-in REST interface, since that interface provides a second path to the Db2 distributed data facility (the other path being the SQL path which could also be called the DRDA path - more on that in the next entry I'll post to this blog).

Big is likely to get bigger

These upward trends, regarding Db2 buffer pool configuration sizes and DDF transaction volumes, are two that I like to see. The former reflects growing recognition that large IBM Z server real storage resources can be very effectively leveraged to turbocharge Db2 application performance, and the latter shows that Db2 for z/OS is an increasingly popular choice as the data server for modern, multi-tiered, client-server applications that access data through standard interfaces (e.g., JDBC, ODBC, ADO.NET, REST). How big will Db2 buffer pool configurations get in the years to come? How high will DDF transaction rates go? We'll see. My take is that big - even really big - is going to get a lot bigger still.

Friday, July 27, 2018

Db2 for z/OS: Using the Profile Tables to Direct DDF Applications to Particular Package Collections

I've posted several entries to this blog on the topic of high-performance DBATs (for example, one from a few years ago covered a MAXDBAT implication related to high-performance DBAT usage). You may well be aware that a "regular" DBAT (a DBAT being a DDF thread) becomes a high-performance DBAT when a package bound with RELEASE(DEALLOCATE) is allocated to the DBAT for execution. How do you get a RELEASE(DEALLOCATE) package allocated to a DBAT? Well, for a DDF-using application that calls Db2 stored procedures, it's easy: bind the packages of frequently-executed stored procedures with RELEASE(DEALLOCATE) and, boom - you get high-performance DBATs when those stored procedures are called. The same goes for packages associated with DDF-using applications that issue static SQL statements from the client side (for example, Java programs that use SQLJ instead of JDBC): bind those packages (the ones that are executed frequently) with RELEASE(DEALLOCATE) and you get high-performance DBATs when the corresponding programs are executed.

Here's the thing, though: there are plenty of DDF-using applications that don't involve execution of static SQL in any form: not in stored procedures, not issued from client-side programs. Can these applications use high-performance DBATs? Sure, they can. Those applications use packages. Which packages? The IBM Data Server Driver packages, of course (these are also referred to as Db2 Connect packages - the Data Server Driver is the more modern version of the Db2 client software). The Data Server Driver packages are bound, by default, into a collection called NULLID. Could they be bound into NULLID with RELEASE(DEALLOCATE)? Yes, but that would NOT be a good idea. Why? Because that would cause all DDF work, by default, to run by way of high-performance DBATs. The optimal set-up is to limit high-performance DBAT usage to your higher-volume DDF-using applications (especially those characterized by transactions that have a low average in-Db2 CPU time - maybe just a few milliseconds). How could that be done, if the NULLID packages are bound with RELEASE(COMMIT)? Easy: you direct the higher-volume DDF applications to a collection, other than NULLID, into which the IBM Data Server Driver packages were bound with RELEASE(DEALLOCATE). And how is that accomplished? Well, for a while the aim was achieved by changing a client-side data source property to point to the alternate Data Server Driver package collection (the one associated with RELEASE(DEALLOCATE) packages) instead of the default NULLID collection. Actually getting the client-side change done? There's the rub: you had to rely on an application server administrator or a client-side programmer to do the deed, and those people were already busy and your change request might not be acted upon - or at least, might not be acted upon in the near future. Oh, for a way to do that Data Server Driver package collection redirect from the Db2 side!

In fact, you can direct a DDF-using application to a collection other than NULLID by way of a  Db2-side action, and that Db2-side capability is the crux of this blog entry.

The solution: you cause the value of a special register to be set automatically for a given DDF application. The special register of interest here is CURRENT PACKAGE PATH, and the means of accomplishing, on the Db2 for z/OS server side, the automatic setting of the special register for a particular DDF-using application is a Db2 profile and an associated profile attribute. I'm talking about the Db2 profile tables, SYSIBM.DSN_PROFILE_TABLE and SYSIBM.PROFILE_ATTRIBUTES. First, the profile: by way of a row inserted into SYSIBM.DSN_PROFILE_TABLE, you identify the DDF-using application for which you want high-performance DBATs to be used. That could be done in several ways, such as through the authorization ID the application uses in connecting to the Db2 for z/OS system. Alternatively, you could identify the application using the IP address (or addresses) of the server(s) on which the client application runs. There are other application identifier options, as well - check them out in the Db2 for z/OS Knowledge Center on the Web. Note that wild cards can be used with DSN_PROFILE_TABLE application-identifier values, so that one profile could cover a set of application server IP addresses, or a set of application-utilized authorization IDs that begin with (for example) the characters CRM (so, the value CRM* in the AUTHID column of DSN_PROFILE_TABLE would apply to authorization IDs CRM01, CRM02, CRM03, etc.).

With the profile row entered into DSN_PROFILE_TABLE, you're ready to set up the attribute that will cause the application of interest to use the IBM Data Server Driver (or Db2 Connect) packages in collection HIPRFCOLL (if that's what you name the collection with RELEASE(DEALLOCATE) packages) instead of those in the NULLID collection. To do that, you insert a row into SYSIBM.DSN_PROFILE_ATTRIBUTES with a value in the PROFILEID column that matches the PROFILEID value in the DSN_PROFILE_TABLE row for the application with which you're working. In that DSN_PROFILE_ATTRIBUTES row, place the value SPECIAL_REGISTER in the KEYWORDS column, and set the value of the ATTRIBUTES1 column to this character sting (again using HIPRFCOLL as the name of the collection into which Data Server Driver packages were bound with RELEASE(DEALLOCATE)):


And you're done: the application associated with the profile will use the IBM Data Server Driver (or Db2 Connect) packages in the HIPRFCOLL collection, and so will utilize high-performance DBATs because the packages in HIPRFCOLL are bound with RELEASE(DEALLOCATE). You can read more about setting special registers via profiles in the Db2 for z/OS Knowledge Center.

Now, I've focused on alternate collections (alternate relative to NULLID, that is) as a means of getting high-performance DBAT functionality for DDF applications that don't otherwise use packages because there is a lot of interest in high-performance DBATs these days. Think, though, about other ways in which NULLID-alternative collections could be useful in your DDF application environment. What if you want certain DDF applications to run with ARCHIVESENSITIVE(NO) behavior, instead of the default ARCHIVESENSITIVE(YES)? What if you want certain DDF applications to run with an isolation level other than the default CURSOR STABILITY? What if you want to use statement concentration (i.e., the automatic parameterization by Db2 of queries that contain literal values in predicates) for certain DDF applications (starting with Db2 12, that can be "turned on" by way of the package bind option CONCENTRATESTMT)? By using profiles to direct DDF applications to Data Server Driver (or Db2 Connect) collections holding packages bound with the desired options and specifications, you can get the application behavior you want, without placing on client-side folks (application server administrators or application developers) the burden of using particular data source properties or coding SET statements for various Db2 special registers (and keep in mind that we're talking here about DDF applications that do not rely completely on Db2 stored procedures, as stored procedures provide you with a great deal of server-side control over application behavior, including package bind specifications).

For a long time, we've been accustomed to NULLID being the one and only collection for the IBM Data Server Driver / Db2 Connect packages, but with many DDF-using applications being of the type that use only (or at least primarily) those packages, and with a growing desire and need to establish behaviors for those applications that can be most readily implemented through Db2-side direction of the applications to collections with packages bound with particular option specifications, it will become more and more commonplace for Db2-using organizations to have multiple collections for the Data Server Driver / Db2 Connect packages, with direction of applications to collections accomplished via Db2 profiles as described above. Remember: in all likelihood it would be best for the packages in your NULLID collection to be bound with standard default specifications, so that applications for which specialized functionality is desired can be selectively directed to the Data Server Driver / Db2 Connect collections containing the packages bound with the options and specifications that can enable the desired functionality and behavior. Using the Db2 profile tables to set the CURRENT PACKAGE PATH special register is a great way to implement server-side direction of DDF applications to Data Server Driver / Db2 Connect package collections. Give this some thought and give it a try if you think it would be useful in your Db2 for z/OS environment.

Tuesday, June 26, 2018

Db2 for z/OS PBG Table Spaces: The Ins and Outs of Partition Addition

In an entry posted to this blog about three years ago, I advocated for putting some thought into the PBG versus PBR decision (partition-by-growth versus partition-by-range) for larger tables (for smaller tables, PBG is often the sensible choice, especially when the associated table space is likely to have only one partition). I pointed out in the aforementioned blog entry several advantages pertaining to PBR table spaces in a large-table context, but acknowledged as well the attractiveness of PBG table spaces from a DBA's perspective (easy to define, pretty easy to administer). In the entry I'm writing today, I want to shed some light on an aspect of PBG table spaces that is a) important, b) not often taken into account, and c) not very well understood by a lot of Db2 people. What am I talking about? Partition addition - in particular, the dynamic and automatic adding of a partition by Db2 to a PBG table space as needed to provide space for more table rows.

Now, you might be thinking, "I'm quite familiar with that mechanism. It's one of the features that I most like about PBG table spaces. When partition n of a PBG table space gets full, Db2 automatically adds partition n+1, to accommodate addition row-insert operations." The thing is, if that's your understanding of how PBG partition addition works then your understanding is a bit off the mark (aside from an exception I'll get to momentarily).

Here's the straight skinny: if a PBG table space has n partitions, Db2 will add partition n+1 not when partition n is full, but when the table space is full. Consider a PBG table space with 100 partitions. Partition 100 gets full. When will partition 101 be added? Partition 101 will be added when Db2 verifies that ALL of the table space's partitions are full: Db2 will check partitions prior to partition 100 - all 99 of them, if needs be - to see if space for a new row can be found. If no space is found in any of the table space's partitions, partition 101 will be added to hold a new row.

If receiving that bit of information has you felling as though you're about to break into a cold sweat, settle down. This doesn't necessarily mean that you've made a mistake in going the PBG route for a large table. Let's consider a couple of scenarios:

  • Table gets inserts, but no deletes. In this case, yes, Db2 will check all partitions of the table space before adding a new one to accommodate a new row, but that space-check will be really fast: with a quick look at the "end" of a partition (referring to the end of the data in the partition), Db2 can determine if there is space available for a new row.
  • Table has a continuously-ascending clustering key. With such a clustering key in effect (every new row has a clustering key value that is greater than that of any pre-existing row), a new row should always go to the end of the table. That can make APPEND YES a viable choice for the table, and when a table in a PBG table space is defined with APPEND YES then Db2 will NOT look in all of the table space's partitions before adding a new partition to accommodate a new row: if partition n is full then partition n+1 will be added, regardless of whether or not space for the row is available in a partition other than partition n (that's the exception to the check-all-partitions rule that I mentioned up in the second paragraph of this entry). Caveat: APPEND YES can lead to an insert "hot spot" at the end of the table, and that could be an issue in a high-volume insert situation. In that case, going with MEMBER CLUSTER for the PBG table space, in addition to APPEND YES for the table, could enable achievement of the desired level of insert throughput.

What if you have a situation that is not like either of the two scenarios described above? What if you have a PBG table space that has, or is likely to eventually have, a large number of partitions? Should you be anxious about the possibly negative performance impact of an all-partition search for space that would precede dynamic addition of a new partition to a PBG table space? I think maybe not. Below I've provided some points to ponder. One or more of them may assuage your worries.

  • Partition size can be a mitigating factor. You have, of course, a number of options with regard to the DSSIZE specification for a PBG table space (DSSIZE indicates the size of the table space's partitions). Why do I bring this up? Because, for a given volume of data rows, a larger DSSIZE means fewer partitions, and as a general rule the backward search for space in previous partitions that precedes the automatic adding of a new partition to accommodate more data will be accomplished more quickly if there are fewer larger partitions versus a greater number of smaller partitions. Now, before jumping to the conclusion that DSSIZE 256G (the maximum value for a PBG table space) is the way to go, consider that there can be challenges in managing larger data sets. That said, it could be that a specification of DSSIZE 32G or 64G could be a better choice than 2G or 4G for some of your larger PGB table spaces.
  • Online REORG can add a partition to a PBG table space before it's needed to accommodate new rows. You may already be aware that a REORG of an entire PBG table space can result in a new partition (or partitions) being added to the end of the table space - that will happen if the reestablishment of free space (e.g., as specified through the table space's PCTFREE value) via REORG requires additional space beyond that in the table space's existing partitions. What you might not know is that Db2 12 for z/OS added a nice enhancement pertaining to REORG of a partition (or partitions) of a PBG table space. The background: prior to Db2 12, if you executed a partition-level REORG for a PBG table space, and the data in a partition would not fit in the partition with free space reestablished by REORG, the utility execution would fail (that's why the ZPARM parameter REORG_IGNORE_FREESPACE was introduced - you could set that parameter's value to YES to cause Db2 to use 0 for PCTFREE and FREEPAGE for a partition-level REORG job). With Db2 12, if a partition of a PBG table space is REORGed and the partition's data won't fit in the partition with free space reestablished, Db2 will add a partition to the table space to hold the overflow rows - the utility job won't fail (and the REORG_IGNORE_FREESPACE parameter is no longer part of the ZPARM module).
  • You can "pre-allocate" some partitions at CREATE TABLESPACE time. Do you think that the NUMPARTS option of CREATE TABLESPACE is only applicable to PBR (partition-by-range) table spaces? If so, time to update your thinking. When you create a PBG table space, NUMPARTS (if specified) tells Db2 how many partitions to initially create for the table space (unless you also specified DEFINE NO in the CREATE TABLESPACE statement); so, with a few partitions available from the get-go, it could be a while before a space constraint would induce Db2 to automatically add another partition for a PBG table space.
  • You can add the "next" partition yourself, with a SQL statement. If you have a situation in which a PBG is approaching "full" status and you're concerned about an "exhaustive backwards partition space search" that would precede automatic addition of a new partition, you can preclude that space search by simply adding the next partition yourself. How would you do that? With an ALTER TABLE ADD PARTITION statement, of course. Oh, you were under the impression that that statement could only be used with a PBR table space? Join the club - I thought that myself, and for quite some time after it was no longer true (ALTER TABLE ADD PARTITION became applicable for PBG table spaces starting with Db2 10 for z/OS). Anyway, you could monitor (using Db2 real-time statistics information) the full-ness of a PBG (or of the last partition of a PBG - particularly in the case of a continuously-ascending partitioning key), and if it looks as though a new partition might soon be needed, add it yourself.

OK, to sum up: if you had assumed that a new partition got added to a PBG table space when the last partition could no longer accommodate a row insert, you need to set that assumption aside (except for the previously mentioned APPEND YES scenario) and understand that an exhaustive backwards search through preceding partitions - potentially through ALL preceding partitions - for row-insert space will occur before a new partition will be automatically added to the table space. Keep in mind that in some cases (especially when there are fewer larger partitions versus lots of smaller ones, and particularly when the table in question hasn't seen row-delete action), that space search will conclude quite rapidly. When the PBG table space has a large number of partitions, and when there have been DELETE as well as INSERT operations targeting the table in the table space, the exhaustive space search preceding automatic addition of a new partition could take longer to complete. In such situations, keep in mind that REORGs (of the entire table space, or - with Db2 12 - of one or more partitions of the table space) can result in added partitions that can hold new rows. Also remember that NUMPARTS can be used to "pre-allocate" partitions at CREATE TABLESPACE time, and that ALTER TABLE ADD PARTITION is a means by which you can add a new partition to a PBG table space at a time of your choosing.

Can PBG table spaces still provide ease-of-use benefits for DBAs, even for very large (i.e., multi-partition) tables? Sure they can. It's just that they are not quite so "set-it-and-forget-it" as you might have thought. With a clear-eyed understanding of how PBG partition addition works, you can take the steps needed to make PBG table spaces work well for you.

Thursday, May 24, 2018

Db2 for z/OS Buffer Pools: Index Root Pages and the Data Management Threshold

Sometimes, a change in the way Db2 for z/OS manages its resources is introduced, and the change "flies under the radar" (i.e, it escapes the notice of most Db2 users) because it is relatively small in terms of scope and impact and is not widely highlighted in the product documentation, and it delivers the intended benefit (e.g., enhances CPU efficiency for data access) and no one thinks about it -- BUT, it may have a consequence that pops up in a surprising way, causing, initially, some confusion on the part of a Db2 administrator before the "what" and "why" of the perplexing situation is understood. In this blog entry, I'll describe a scenario of this nature. It has to do with index root pages and something called the buffer pool data management threshold.

A Db2 for z/OS consultant working in Europe brought this matter to my attention. This consultant's client had, in a test environment, a Db2 for z/OS buffer pool that kept hitting the data management threshold, and the consultant could NOT figure out why this was happening.

Some background: the data management threshold relates to Db2 buffer pools -- it's hit when 95% of the buffers in a pool are non-stealable, with "non-stealable" meaning "in-use or updated-and-not-externalized (i.e., externalized to disk or to a group buffer pool in a Db2 data sharing system)." You don't want the data management threshold to be reached for a buffer pool. Why? Because when DMTH (the acronym that refers to the threshold) is hit for a buffer pool, Db2 will issue a GETPAGE for every row retrieved from a given page in the pool; so, if 20 rows are to be retrieved from a page in a buffer pool that has hit DMTH, Db2 will issue 20 GETPAGE requests instead of one. That, in turn, will drive up overhead for access to data cached in the pool, as GETPAGEs are a major factor with regard to the CPU cost of SQL statement execution.

So, why did the pool in question regularly hitting DMTH perplex the consultant? Because the pool, though not real big, was not tiny (10,000 4K buffers), and the deferred write thresholds were at their default values (30 for DWQT, aka the horizontal deferred write threshold, and 5 for VDWQT, aka the vertical deferred write threshold), and the pool wasn't all that active (about 200 GETPAGEs per second, and just a few read I/O operations per second). With the pool's deferred write thresholds being at their default values and the pool not being particularly busy and not being particularly small, no way should DMTH be getting hit due to a large percentage of the pool's buffers being in an updated-but-not-externalized state. THAT would have to mean that DMTH was being hit because a very large percentage of the pool's buffers were in an "in-use" state. But how could that be, given the relatively non-busy state of the pool (200 GETPAGEs per second is nothing -- I've seen plenty of pools with thousands, or tens of thousands, of GETPAGEs per second).

Digging a little further for answers, the consultant used a Db2 monitor to get a more detailed view of the usage of the buffer pool for objects assigned to it. What he saw left him even more puzzled: the pool had about 10,000 indexes assigned to it (keep in mind, this is a test environment we're talking about), and a little over 9000 of those indexes each had a single "currently in-use" page in the pool. That number of in-use pages explained why DMTH was often being hit for the buffer pool (as I mentioned, buffers holding in-use pages are non-stealable, just as are buffers holding updated-but-not-externalized pages), but how could so many pages be currently in-use for a fairly low-activity pool, and why would almost all of the currently in-use pages be the ONLY in-use page for a given index? The consultant scoured the Db2 documentation in search of an explanation, and that's where he found the key that unlocked the mystery -- not in the Administration Guide, not in Managing Performance, but in the What's New manual for Db2 10 for z/OS. There, in an unexpected location (under the heading, "Reduction in need for explicit REORG"), he saw these words (color highlighting added by me):
DB2 10 provides several performance enhancements that reduce the need to reorganize indexes frequently, resulting in a reduction in CPU time and synchronous I/O waits. Compared to DB2 9, in DB2 10 you might see increased activity in deferred writes because more buffers are in use by buffer pools to improve performance. For example, activity might increase for index root pages that are pinned in a buffer pool when the index page set or index partition is opened.
(You can check this out for yourself here.)

And there you have it. This is one example -- there are plenty more -- of the Db2 for z/OS development team effecting changes that aim to leverage larger memory resources (increasingly common for z/OS systems) for enhanced performance. Index root pages are accessed a lot, and memory is becoming more plentiful on IBM Z servers, so why not "pin" those pages in the associated buffer pools at index open time, to guarantee that they'll be there when we need to read them?

OK, for a buffer pool analyzed by the aforementioned Db2 consultant, the pinned index root pages caused a DMTH problem. Does that mean that this is a "Watch out!" kind of situation in a general sense? I would say, "No." The problem described herein was encountered in a test environment, with a buffer pool that is on the small size (as mentioned, 10,000 4K buffers) and which has assigned to it a very large number of indexes (as mentioned, about 10,000). In my experience, I have NEVER encountered a situation in which a buffer pool in a production Db2 system hit DMTH due to index root pages being fixed in the pool. In production environments, buffer pools are often quite large (sometimes hundreds of thousands -- or even several million -- buffers in a single pool), and they often have assigned to them something less than 10,000 objects (and keep in mind that fixed-in-the-pool root pages are only relevant to indexes -- not table spaces). No, the reason I've written this blog entry isn't to warn you about a problem situation that is quite likely to occur in a production Db2 system. I've written this piece because you, like the consultant to whom I have referred, could conceivably encounter this buffer pool DMTH issue (probably, if at all, in a test or development environment), and if you do then having the information I've provided could save you some problem identification time and associated worry and consternation.

If in fact you encounter the index-related buffer pool DMTH situation described in this blog entry (not likely), and if you want to make it go away, the best move would probably be to add buffers to the pool in question. If the system is memory-constrained so that you can't do that, consider taking one or more of these steps:
  • Reassign some of the objects assigned to the buffer pool to a different buffer pool.
  • Lower the DSMAX value for the subsystem, so that some index data sets will periodically be closed before the buffer pool fills up with "pinned" index root pages.
  • In a data sharing environment, have the indexes defined with CLOSE YES so that the data sets will be closed when they have gone a while without being accessed from a given Db2 member.

Monday, April 30, 2018

Db2 for z/OS Buffer Pools - Time to Give AUTOSIZE(YES) a Try?

Db2 9 for z/OS became generally available back in 2007. In the years since, most of the features introduced with Db2 9 have been broadly put to use. An interesting exception is the auto-sizing of buffer pools, implemented via the AUTOSIZE(YES) option of the -ALTER BUFFERPOOL command. Based on my experience, it seems that few Db2 for z/OS sites have gone with buffer pool auto-sizing. I find that a bit perplexing. In the Db2 for Linux/UNIX/Windows user community, a feature called self-tuning memory (which applies to buffer pools and more) appears to be quite popular. Why the seeming reluctance to leverage buffer pool auto-sizing in Db2 for z/OS systems?

I'm thinking that we may be seeing a situation not unlike the one that existed back in the 90s and early 2000s vis-a-vis SMS-management of Db2 for z/OS data sets (SMS is short for System-Managed Storage, a capability provided by the z/OS operating system). Db2 management of table space and index data sets, enabled through a specification of USING STOGROUP (instead of USING VCAT) in a CREATE TABLESPACE or CREATE INDEX statement (or in an ALTER of an existing object), had become commonplace, but many Db2 DBAs and systems programmers were reluctant to take the additional step of letting SMS take care of data set placement within a disk subsystem. Folks were fine with Db2 issuing the Access Method Services commands that were needed to create data sets (what you get with USING STOGROUP), but letting the system handle data set placement was another matter. The thought of having VOLUMES('*') in a CREATE STOGROUP statement, which would hand data set placement responsibility over to SMS, made lots of Db2 systems people uneasy - they just didn't trust z/OS to get that done right; so, folks would create STOGROUPs that were associated with particular disk volumes (e.g., CREATE STOGROUP SGPRD01 VOLUMES(ABC123), CREATE STOGROUP SGPRD02 VOLUMES(XYZ139), etc.), and they would then assign individual Db2 data sets to this STOGROUP or that one - in effect, hand-placing the data sets within a disk subsystem - so as to ensure that the data sets in question went on different disk volumes. "I want to make sure that partition 1 of partitioned table space TS1 doesn't go on the same volume as partition 2 of that table space," they'd say; or, "I want to make sure that index IX1 goes on a volume other than the one holding the table on which IX1 is defined."

This very hands-on approach to Db2 data set placement started to become a major burden on DBAs and systems programmers as Db2 databases mushroomed in size and the number of data sets associated with Db2 databases shot up. Something had to give, and so some Db2 systems people - not without trepidation - decided to let SMS do a job that had become too big to handle via the old hand-placement approach. I had recently started work in the IT department of a Db2 for z/OS-using organization, back in 2000 (between my two IBM stints), when our lead z/OS systems programmer told me that she was going to go with SMS-management of Db2 data sets in production. She just hoped that the performance penalty wouldn't be too severe. Guess what? At our site, and at other sites, SMS management of Db2 data sets worked just fine. Performance didn't suffer, and tons of Db2 administrator time got freed up for use in higher-value activities. Within a short time, SMS management of Db2 data sets became the norm. Key to that development: the old approach (hand-placement of Db2 data sets within disk subsystems) became increasingly untenable, and technology advances made old worries concerning the new approach (SMS management of Db2 data sets) largely moot (z/OS and IBM Z and disk storage improvements made contention at the spinning-disk level much less of a concern than it had been in the past).

Today, a Db2 administration practice that ought to be reexamined is micro-management of buffer pools. Historically, people have sliced and diced buffer pool memory usage in a very fine-grained way. With ongoing growth in the size and number of Db2 subsystems that individual organizations use, and with Db2 for z/OS administration teams being, typically, small in terms of headcount, the time needed to effectively manage Db2 buffer pool sizing is, more and more, just not there. Turning that task over to Db2 (and the z/OS Workload Manager) is an increasingly attractive alternative. At the same time, technology changes have made buffer pool micro-management less worthy of major time commitment: IBM Z memory resources are getting to be huge by recent standards, and as z/OS LPAR real storage sizes soar, super-fine tuning of the use of that space for Db2 buffer pools becomes less and less of an imperative. Not only that, but many a Db2 administrator's mind-set, regarding appropriate buffer pool sizing, has fallen behind the reality of the current hardware situation. What I mean by that: a 10-GB buffer pool configuration (aggregate size of all pools allocated for a subsystem) may seem large in a Db2 administrator's eyes, given historical standards, but in an LPAR with 100+ GB of memory (pretty commonplace these days), that 10 GB looks dinky. It's like z/OS is saying to these people, "Hey, there are a lot of gigabytes in this system that are just lying around, doing nothing. I can see them. Give me and Db2 the keys to the buffer pool sizing car, and we'll put those sleeping gigabytes to work, and application performance will be the better for it. And don't worry about my overloading my own memory resource - I'm not going to do that. I know how to manage what I've got. Give me a chance."

In what I think might have been conceived as an enticement aimed at Db2 people who look askance at system-managed buffer pool sizing, Db2 11 provided "floor" (VPSIZEMIN) and "ceiling" (VPSIZEMAX) options for the -ALTER BUFFERPOOL command: "OK, Db2, I'll turn on auto-sizing for BP10, but I'm not going to let you make the pool smaller than X or larger than Y." I'd say, give that a shot. You can do that for several of your buffer pools (even all of them), or just one. Say you have a z/OS LPAR with lots and lots of memory (when organizations upgrade a mainframe, they often load it with buckets of additional real storage, due in no small part to attractive memory pricing), and a demand paging rate that doesn't vary from zero, even during the busiest processing times of the day (the demand paging rate for an LPAR is available, among other places, in an RMF CPU Summary Report). Say you have in this system a Db2 for z/OS buffer pool (I'll stick with BP10) that is sized at 100,000 buffers. Consider issuing a command of this nature:

  VPSIZEMIN(75000) VPSIZEMAX(150000)

Let the workload go for a while, and periodically issue -DISPLAY BUFFERPOOL(BP10) DETAIL to see what's happening with the pool. Even better, have "before" and "after" activity data for the pool, for the same hour of the same day (e.g., 10-11 AM on a Thursday), from either a Db2 monitor-generated statistics report - long or the output of -DISPLAY BUFFERPOOL(BP10) DETAIL (if you go with the command for activity data, and you want data from 10-11 AM, issue the command at 10 AM and again at 11 AM, and you'll have activity data for that 1-hour period in the output of the second issuance of the command). My expectation would be that things will be fine, and some performance metrics might move in a positive direction. And, the system's demand paging rate will likely still be zero. Next, maybe open up auto-sizing for other pools in your system, again with floor and ceiling values with which you're comfortable. And, go back to a pool for which you previously activated auto-sizing, and, if the system-adjusted pool size is larger than its initial size, try another -ALTER BUFFERPOOL with a larger VPSIZE and larger VPSIZEMIN and VPSIZEMAX values, to let the system take the pool size further in the direction that the system has determined is best for overall performance. Over time, you may well become not only comfortable, but happy, with Db2 and z/OS handling sizing for all of a subsystem's buffer pools.

And, just in case you hear a little voice in your head, saying, "Careful, buddy. You spend a pretty good bit of time on buffer pool sizing. If you let the system handle that then you'll be sitting around twiddling your thumbs, and that's not good," tell that voice to shut up. Did you run out of things to do when you let SMS manage Db2 data set placement? Or when you no longer had to manage index page locking because Db2 stopped doing that kind of locking? Or when you could quit managing the package table part of the EDM pool because Db2 quit using EDM pool space for allocating packages to threads? Or when you let Db2 manage secondary disk space allocation for table space and index data sets with MGEXTSZ=YES in ZPARM and Db2's "sliding scale" algorithm? Of course not. In each and every case in which Db2 and/or z/OS took on tasks you used to do (or Db2 stopped doing things that you used to have to work to manage), you ended up staying plenty busy, with a different mix - a higher value mix - of work. System-managed buffer pool sizing offers another opportunity to move your work mix up the value chain. I think the time's right for more people to take that step. Maybe it's your time.

Monday, April 2, 2018

Another Db2 for z/OS Blog You Should Check Out

If you're reading this, it's probably because you've found blogs to be a useful source of technical Db2 for z/OS information. I want to direct your attention to one of the newer kids on the Db2 blog block: Db2 for z/OS News from the Lab.

What makes the Db2 for z/OS News from the Lab blog particularly noteworthy? It's written by people who are part of IBM Db2 for z/OS development organization - people who call the IBM Silicon Valley Lab home base. These folks, needless to say, know Db2 for z/OS very well. Additionally, these people interact with Db2 for z/OS users all the time, and those interactions provide inspiration for blog entries that can clarify and highlight various facets of the Db2 whole.

So, get wise and get the inside scoop by visiting the Db2 for z/OS News from the Lab blog. Even better, become part of the blog's community - information on doing that can be found in one of the blog's entries. Read and learn!

Wednesday, March 28, 2018

Db2 for z/OS: CACHEPAC is Another ZPARM You Should Check

Sometimes, the default value of a Db2 ZPARM parameter is changed to reflect new realities of Db2 workloads and of systems on which Db2 for z/OS runs. When that happens, a Db2-using organization may stick with the old default value for the ZPARM, and going that route can have a negative impact on the performance of the Db2 system. Case in point: CACHEPAC, the subject of this blog entry.

I've blogged before about ZPARMs that are regularly set to sub-optimal values. I've also posted entries (part 1, part 2, and part 3) on boosting Db2's use of memory so as to improve CPU efficiency for a Db2 workload. CACHEPAC is related to both of those topics.

What is the purpose if CACHEPAC? It specifies the amount of virtual storage, in the Db2 database services address space (aka DBM1), that will be used to cache package authorization information (like, what authorization IDs have the EXECUTE privilege on package XYZ). Is caching that package authorization information important? Yes. Why? Volume - as in, volume of requests for package execution.

Get yourself a statistics report - long generated by your Db2 monitor (depending on the monitor product used, that might be called a statistics detail report), and check the section of the report that contains figures for EDM pool-related activity (alternatively, look at an online display of EDM pool activity provided by your Db2 monitor). Look for a field with a label like PT REQUESTS. PT is short for package table, and this field shows the frequency of requests to execute packages (or sections of packages). For a production Db2 subsystem, you might see hundreds, or even thousands, of requests to execute package sections per second. Having to check the SYSIBM.SYSPACKAUTH table in the catalog for each and every one of those package execution requests would be a drag on performance, for sure; thus, the in-memory package authorization cache specified via CACHEPAC in ZPARM.

It was with Db2 10 for z/OS that the default value for CACHEPAC changed, and changed pretty dramatically. In a Db2 9 environment, the default value for CACHEPAC was 100 KB. With Db2 10, the CACHEPAC default value changed to 5 MB - 50 times larger than before. Why? I suspect the change was made by the Db2 for z/OS development team for several reasons. For one thing, Db2 systems have ever-larger numbers of users and applications (that's more authorization IDs needing package-related privileges), and ever-larger numbers of packages (further upping space needs for package authorization information). Additionally, z/OS LPAR memory resources are getting bigger all the time (hundreds of GB of memory for one z/OS LPAR is not unusual these days), and with more available memory "real estate," why not use more of it for package authorization information caching, to enhance system performance?

Along with Db2 10's boost of the CACHEPAC default value, the maximum value for the parameter was increased - to 10 MB, from 5 MB.

OK, so it's not uncommon to see a Db2-using organization stick with the old default value for a ZPARM when a new default comes along. This might be due, in some cases, to inertia as much as anything. Trouble is, a 100 KB package authorization cache may prove to be WAY smaller than it should be for a Db2 workload that's large by today's standards. I saw a situation of that nature quite recently, in looking over a Db2 monitor statistics detail report sent to me by the Db2 team at a company with which I was working. The report showed that the package authorization cache for a Db2 system that was having occasional performance problems was severely undersized. How could I see that? Easy. In such a report, find a section with a heading like AUTHORIZATION MANAGEMENT. In that section of the report, find the field labeled something like AUTH UNSUCC-PKG-CACHE. That is where you'll see how often a package authorization check could NOT be successfully performed using the package authorization cache. What would you LIKE to see here? Maybe a few package authorization checks per second (in the single digits, or less, per second) that could not be serviced using information in the package authorization cache. What did I see in that report I just referenced? 1098 package authorization requests per second that were not successfully performed via the package authorization cache. Why was this so? It was so because, on a busy Db2 system doing a lot of work for applications, the package authorization cache size, per CACHEPAC in ZPARM, was too small - probably way too small.

So, here's what you should do: use your Db2 monitor to generate a statistics report - long (or, if you can't do that, check an online display of subsystem statistics provided by the Db2 monitor), and find in that report the AUTHORIZATION MANAGEMENT section. In that section, find the field with the label like PKG-AUTH UNSUCC-CACHE. What's the frequency of package authorization checks NOT accomplished by way of the package authorization cache? If that number is in the low single digits (or less) per second, good. If it's up in the double digits per second or higher, the value of CACHEPAC in ZPARM should be increased. If the frequency of package authorization requests not successfully performed using the package authorization cache is really high, like north of 100 per second, CACHEPAC should probably be substantially increased.

What is the value of CACHEPAC for your production Db2 subsystems? If it is less than the default (since Db2 10) of 5 MB, it should probably be increased to 5 MB. If it is at 5 MB and you still see a lot of package authorization requests NOT successfully performed using the package authorization cache, CACHEPAC should probably have a value greater than 5 MB (remember, that value can go up to 10 MB).

Do you have the memory resources on your z/OS LPAR to support an increase in the CACHEPAC value? Probably (if you can't use a few more MB of memory for Db2 without putting the z/OS LPAR's real storage resource under an undesirably high level of pressure, the LPAR likely has a too-small memory allocation). How can you tell if the LPAR's memory is stressed? Check (or have a z/OS systems programmer check) the LPAR's demand paging rate in an RMF (or equivalent z/OS monitor) CPU Summary Report. If the LPAR's demand paging rate is zero, memory is not overly stressed and you should be able to use more for the Db2 package authorization cache (if a CACHEPAC size increase is seen as being needed). I'd also be comfortable with a CACHEPAC size increase if the associated LPAR's demand paging rate were a very small non-zero value (i.e., less than 1 per second). If the LPAR's demand paging rate is 2-3 per second or higher, I'd like to see more memory allocated to the LPAR before substantially increasing CACHEPAC (or, if more memory can't be provided for the LPAR, consider reducing some of Db2's memory use until the demand paging rate is less than 1 per second, and THEN make CACHEPAC larger if it is too small and failing to satisfy a lot of package authorization requests per second).

And that's that. When most all package authorization checks can be successfully accomplished using information in the Db2 package authorization cache, it's a good thing. If you're not there for one or more of your production Db2 subsystems, try to get there.