Sunday, November 20, 2022

 On the Issue Of Handedness


People often ask, after watching me play tennis (which I love), or occasionally darts or billiards:

Are you right-handed or left-handed?  My reply: "Yes!"  

For quite some time now - I'd guess since I was a child, even before I can remember - I do believe this question has come up from time to time.  

I remember my mother bragging that my kindergarten teacher would explain that one day I would finger-paint left-handed, then the next day practice writing my name right-handed.  Then, I got to first grade, and went to a catholic school where being left-handed was considered an inconvenience - all students who wrote lefty were given separate desks on the far side of the room.  I think it was at that point, being quite shy, I decided to always write right-handed.  

This same scenario played out again in sports.  At this point, I was playing baseball and throwing right-handed, but I wanted to bat left-handed.  My Catholic Youth Organization coach said: "If you throw right-handed, you should bat right-handed."  So that is what I did - in organized sports.  I continued to switch hands, seeming to naturally trend left-handed in any sport requiring fine motor skills.  This would go for archery, shooting, darts, softball and tennis (sort of - I served right-handed).   

As the years passed, I grew into a husky kid who could hit a baseball quite well from either side of the plate, but when I reached the age of 13, a stigmatism developed, causing my eyesight to decline.  Wearing glasses was never easy for me while playing sports, so I stopped playing baseball.  Later, when I discovered tennis (at about age 21), wearing glasses was no big deal - except I found myself switching between lefty and righty forehands naturally (an instructor told me I could not do this - then watched for a while, and said "I guess you can?").  

As time went on, and I became an adult, I noticed I did a great many things left-handed, but I'd just never noticed:  cut meat with a knife, sweep with a broom, shovel dirt, deal cards and many more.  I am also a self-taught guitarist of some ability (having played in bands), and of course, I play left-handed!

When I tried to switch and do most of these things with the other hand, I found I probably could, but it was not nearly as comfortable.  People who do some things with one hand, and some with the other are are said to have "mixed laterality" or are cross-dominant.  This was once considered to be a disability by the medical profession, but this was likely due to bias or anecdotal information.  

In any event, I am quite happy with my unique "aflliction".  Less than 1% of the population has it, and in some sports (such as baseball), it can be a distinct advantage.  

Sunday, November 6, 2022

Postgresql Upgrade 12>>>14

As part of a migration to new hardware and a new OS, today we are also upgrading postgresql.  

While it is normally dangerous to mix/match HW/SW upgrades along with DB Engine changes, the client has overgrown their old systems, and this is their last chance before a year-end freeze to upgrade and move to a supported operating system, so we've agreed to help.  

One of the first things that must be done on a new host is to get the Postgres binaries installed, which is done thusly:

dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

/usr/pgsql-14/bin/postgresql-14-setup initdb


systemctl enable --now postgresql-14


systemctl status postgresql-14 


Yes, it can be that simple on a new system!  


This blog post is not really about installation, there are other fine blog posts that go into explicit details of this activity, or you can check the official documentation and download site at postgresql.org.  

Remember, Postgresql is community supported (unless an enterprise support license is obtained), so you should always get installation media from a reputable source, and for the appropriate platform and OS.

One of the first things to do when upgrading is to assure that any custom configuration parameters are carried over to the new system.  Default parameters can change their value from release to release, and new ones are added and depricated.  We will focus on some easy ways to check and verify postgresql.conf and pg_hba.conf to assure they are consistent (where possible) and appropriate for the new environment.  

To check on set values in the existing (Version 12) postgresql.conf, you can run the following command:

[postgres@postgresb data]$ grep -v "#" postgresql.conf | grep -v '^[[:space:]]*$'

max_wal_size = 5GB

archive_command = '/bin/true'

pg_stat_statements.track = all

shared_preload_libraries = 'pg_stat_statements'

track_activity_query_size = 2048

log_timezone = 'America/New_York'

datestyle = 'iso, mdy'

timezone = 'America/New_York'

default_text_search_config = 'pg_catalog.english'


Grep (globally search for a regular expression and print matching linesis a very powerful unix/linux command.  There are variations for it in other OS, but the goal of the above set of commands was to remove commented lines (#) and blank lines, as the delivered file is full of them.  A reference blog post for this command and more can be found here. 


Here is the comparison file for the target (version 14) system:


[postgres@rh-postgresa data]$ grep -v "#" postgresql.conf | grep -v '^[[:space:]]*$'

max_wal_size = 1GB

min_wal_size = 80MB

log_timezone = 'America/New_York'

datestyle = 'iso, mdy'

timezone = 'America/New_York'

default_text_search_config = 'pg_catalog.english'


As we can see, there are a few inconsistencies.  We cannot always be sure, without user documentation, why these settings differ, but the safest thing to do is to make them match, so:


Use vi (or another editor) to make the values match.


It is always best to back up postgresql.conf to another location (not in this same directory) before making any changes.  


Then, reload postgres and check results:


systemctl stop postgresql

systemctl start postgresql


- or - 


systemctl reload postgresql


- or - 


pg_ctl reload -D your-pg-data-directory



In this specific case  pg_stat_statements was an "extension" to the Postgresql binaries, so had to be installed separately. See this blog post as to how that is done.  



This was a long one.   I will follow up with more details on how the implementation turned out.