Wednesday, 31 July 2019

[Db2 LUW] When is a table reorg needed?

Some operations on a table of a Db2 instance let the table in an unusable state. I shall try to list the operations. Please be aware the list is probably not complete!

Require reorg

  • drop at least one column
  • increase the size of a decimal column

Do not require reorg

  • add columns (at least 5 are possible, did not test more)
  • increase the size of a varchar column

[Db2 LUW] buggy (left) outer join?!?

Problem

Following queries lose against DB2 v11.1.1.1 fixpack number 1(Linux) lose the left row without match on the right side.
with G as
    (select   *
        from ADW_ETL.ETL_GDT_UNIQUE_KEY
        where TABLE_NAME in('BAP_KOMMUNIKATION',
                            'BAP_GESCHAEFTSVORFALL',
                            'BAP_GFSCHRITT',
                            'BAP_GFSCHRITTADD',
                            'BAP_AUFTRAG',
                            'BAP_AUFTRAGPRODUKT')
    )
  select   G.TABLE_NAME,
      C.FLAG_ACTIVE,
      G.STORE_FLAG,
      G.OGG_PACKER_FREQUENCY,
      C.DWH_TIME_DELAY,
      I.*
    from G
    left outer join ADW_STATMON.DWH_ODS_CTRL C
    on G.TABLE_NAME = C.DWH_ODSCTRL_GDT_NAME
    left outer join ADW_STATMON.DWH_INBOUND_REG I
    on I.DWH_TRG_TABLE_NAME = G.TABLE_NAME
    where nvl(I.DWH_REG_TS, current_timestamp) >= current_timestamp - 9
;
with G as
    (select   *
        from ADW_ETL.ETL_GDT_UNIQUE_KEY
        where TABLE_NAME in('BAP_KOMMUNIKATION',
                            'BAP_GESCHAEFTSVORFALL',
                            'BAP_GFSCHRITT',
                            'BAP_GFSCHRITTADD',
                            'BAP_AUFTRAG',
                            'BAP_AUFTRAGPRODUKT')
    )
  select   G.TABLE_NAME,
      C.FLAG_ACTIVE,
      G.STORE_FLAG,
      G.OGG_PACKER_FREQUENCY,
      C.DWH_TIME_DELAY,
      I.*
    from G
    left outer join ADW_STATMON.DWH_ODS_CTRL C
    on G.TABLE_NAME = C.DWH_ODSCTRL_GDT_NAME
    left outer join ADW_STATMON.DWH_INBOUND_REG I
    on I.DWH_TRG_TABLE_NAME = G.TABLE_NAME
    where I.DWH_REG_TS                         >= current_timestamp - 9
       or I.DWH_REG_TS                         is null
;
I am pretty sure it is not iso standard behavior, and to me counterintuitive for sure.

Solution

Either pack the filtering into with constructs or move the filter on the outer table (the one not necessarily retaining its records) into the on clause. Example for the latter:
with G as
    (select   *
        from ADW_ETL.ETL_GDT_UNIQUE_KEY
        where TABLE_NAME in('BAP_KOMMUNIKATION',
                            'BAP_GESCHAEFTSVORFALL',
                            'BAP_GFSCHRITT',
                            'BAP_GFSCHRITTADD',
                            'BAP_AUFTRAG',
                            'BAP_AUFTRAGPRODUKT')
    )
  select   G.TABLE_NAME,
      C.FLAG_ACTIVE,
      G.STORE_FLAG,
      G.OGG_PACKER_FREQUENCY,
      C.DWH_TIME_DELAY,
      I.*
    from G
    left outer join ADW_STATMON.DWH_ODS_CTRL C
    on G.TABLE_NAME = C.DWH_ODSCTRL_GDT_NAME
    left outer join ADW_STATMON.DWH_INBOUND_REG I
    on I.DWH_TRG_TABLE_NAME = G.TABLE_NAME
    and I.DWH_REG_TS >= current_timestamp - 9
;

Friday, 19 July 2019

[git] Get the unpushed commits of a local repository and their commit timestamp using zsh

Run within the local repository
_LOG="$(git log)"
for _COMMIT in "${(@f)$(git cherry -v)}"
# '${(@f)VARIABLE}' splits VARIABLE (can be command substitution) at linebreaks (otherwise it would get split into words)
do
    _DATE_STRING=$(echo "${_LOG}" | grep -A2 ${_COMMIT[(w)2]} | grep -F Date)
    # (w) spilts into words, [..2] takes the second element
    echo "${_DATE_STRING}  ${_COMMIT}"
done
or as oneliner
_LOG="$(git log)" ; for _COMMIT in "${(@f)$(git cherry -v)}" ; do _DATE_STRING=$(echo "${_LOG}" | grep -A2 ${_COMMIT[(w)2]} | grep -F Date) ; echo "${_DATE_STRING}  ${_COMMIT}" ; done

Wednesday, 15 May 2019

[Db2 LUW] Source for arbitrary record

I sometimes are in need for a source of an arbitrary record, e. g. to test some function. In Oracle you can use DUAL. In Db2 LUW (to make it clear what DB I am referring to, I know LUW is officially not used anymore by IBM) there is a compatibility vector thing which provides DUAL as well. But it is not installed, switched on, activated or whatever one has to do to make it usable, one can use SYSIBM.SYSDUMMY1.

Thursday, 9 May 2019

[screen] Howto scroll back

screen
is a terminal multiplexer pretty useful when you want to have several terminals over one single remote connection and also if you want disconnects not effect your sessions.

However, when in screen you cannot just scroll back. Longtime I just thought it would not be possible but it is. You need to enter scrollback/copy mode by [ctrl]-[a] [esc].

Tuesday, 30 April 2019

[Windows 10] After startup CPU and I/O gets hogged

If the culprit for this is WUDFHost.exe or something like that, I actually have not found a solution so far. Apparently, it has to do with media library synchronisation when you plugin a portable device.

  • Some mention you should just disable this device in the device manager, but it did not help with me. At least the device stayed usable.
  • Killing the process is cumbersome. First of all, you need to have admin role to do so. Apparently people suggesting the kill, do not restrict their usual user with removing that role. But much more important, the WUDFHost process started again immediately after the kill.
  • Rename the WUDFHost.exe (alternatively remove it), but as it is owned by "Trusted Installer" it is a bit tedious and in my case did not help. Maybe after a reboot, things look brighter. However, to do as mentioned:
    1. Get admin rights and change the owner of the file (C:\Windows\system32\WUDFHost.exe) best to Administrator.
    2. Rename the file with admin rights.

Saturday, 13 April 2019

[Windows 10] login screen/switch user list misses user

Prologue

I installed Windows 10 anew as it borked itself up for an unknown reason. However, as usually I activated the administrator account and kicked my personal (initial) user out of the administrators group. After reboot I was rather pissed when I did not have my personal user in the login screen and in the switch user list (I do not know the correct term for it, but it is the list showing up when clicking on the start button and then on the user button - the icon showing a bust).

Solution

  • I added the group "Benutzer"/users to the user in the Microsoft Management Console.
  • I changed the registry entry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\UserSwitch\Enabled to 1

After math

I am not sure whether both measures were needed.

[git] Create a local branch from another branch

From the active branch git checkout -b <LOCAL_BRANCH> From a donator branch git checkout -b <LOCAL_BRANCH> <DONATING_BRANCH...