Inspecting Joins in PostgreSQL

Man on the computer.

Introduction

Relational databases distribute their data across many tables by normalization or according to business entities. This makes maintaining a growing database schema easier. Real-world queries often span across multiple tables, and hence joining these tables is inevitable.

PostgreSQL uses many algorithms to join tables. In this article, we will see how joins work behind the scenes from a planner perspective and understand how to optimize them.

Protect Your Invariants!

How do you handle constraints and validation inside your application? Most developers put this logic somewhere close to their application's boundary. Actually, this prevents them from having a rich domain model that could ensure consistency.

Developers tend to get confused when they need to find a good place for their business logic. I suspect that most probably the reasons are related to all those bad examples circulating in the documentations of popular frameworks and bad habits from coding in old-fashioned enterprise platforms like J2EE. Most of the time, they're afraid to keep these vital pieces of information in the language elements most relevant to the target domain: I'm talking about the simple classes reflecting the "nouns" of the business logic. Often, you see something like the example below:

New WordPress Plugin Offers a Markdown Editor Solution

Earlier today, a new editor plugin named Markup Markdown landed in the WordPress directory. It replaces both the classic and block editors with a Markdown solution. It is the first plugin by an author simply known as Peter, or @peter202202.

As someone who almost always writes in Markdown, I did not think twice about downloading, installing, and activating it. I was pleasantly surprised to find a decent editor that I enjoyed — after making a few changes, at least.

The plugin is not complicated to use. If you are familiar with writing in Markdown, you need to only activate it. There are no settings. Markup Markdown replaces the editor for all post types with its own.

WordPress post-editing screen.  The editor canvas has been replaced with a Markdown editor.
Markup Markdown editor.

The plugin relies on the Parsedown PHP library to handle front-end output, turning the Markdown into HTML. On the backend, it uses the EasyMDE script for a JS-based editor.

While I am generally a fan of option-less plugins, this one could use a few. At the very least, users should get to choose which editor they prefer via their profile. On a multi-author site like the Tavern, not having this option means the plugin is a non-starter. I would also like to choose between editors for individual posts. It does not make sense for one already written in blocks to be edited in Markdown.

The biggest issue I ran into with the plugin’s editor was that the font size was far too small and the content area too wide for comfortable writing. Therefore, I made a few CSS adjustments to make it more to my liking.

WordPress editor with narrow Markdown editing canvas.
Custom CSS adjustments.

Without these adjustments, I genuinely liked the plugin. However, the older I get, the more crucial readable typography becomes. My eyes prefer the change.

In the future, I would like to see the plugin author at least use the theme-defined content width to set the writing area. With theme.json files becoming standard, I would pull typography-related styles in too. It does not need to do much — no need to try to go for a WYSIWYG experience.

An alternative would be to add a few design options for configuring the editor. A handful of settings would go a long way in creating a more user-friendly experience.

For the most part, I enjoyed tinkering with Markup Markdown. If this were five years ago, I would already have it on all my sites. And, it is likely an ideal solution for many Markdown lovers today.

I still prefer the overall interface of the modern post-editing screen. I feel like I am traveling through time whenever I encounter the classic version. It is jarring enough that I doubt I would seriously use this plugin today. I would prefer a Markdown solution built on top of the block system.

One downside of the plugin is that it may not work alongside some block themes. Some rely solely on theme.json-generated styles at the block level to handle their design. This means that valid HTML output not generated by the block system may be left unaccounted for.

For example, the following <img> (image) tag wrapped inside <p> (paragraph) blows out of the layout when using Twenty Twenty-Two:

Twenty Twenty-Two WordPress theme output where a large image breaks out of the content on the right side of the screen.
Twenty Twenty-Two fails to contain large image.

There is nothing wrong with the HTML, and it is the standard way Markdown outputs images. This mistake is from the theme, not the plugin. The design is not accounting for large images when not output by a block. This is something that nearly all classic themes handle.

A theme that covers all its bases will show the following:

Custom theme post design that keeps its content contained when a large image is on the page.
Custom theme that contains image.

I love block themes, but this is something to watch out for if using one alongside this plugin. Most of those I tested did not handle this scenario. This same problem could affect content written in the classic era or custom HTML.

While on the subject of images, the plugin sticks with pure Markdown output. It has a button for pulling up the media library, but there is no way to insert anything but the full-sized image. Alignment classes are not available either.

The latter problem could be solved if the plugin bundled Parsedown Extra, a Parsedown extension that supports Markdown Extra. The specification allows “special attributes.” As someone who routinely writes in Markdown, I almost exclusively use this feature to add classes to images.

Overall, the plugin is a solid solution for those looking for a Markdown-based editor. With it being a 1.x release, I look forward to seeing where it goes in the future.

sub of a event handler (dynamically generated, combobox, textbox, button)

Hi all, I have created an Event handler to a function for clicking a generated button, now when this button is clicked need to paste in a textbox the Combobox.seleteditem (that it's a string. Each generated one (Combobox, textbox, button) will have a selected index of the Combobox that it's different, but that is not the problem because I put it in an if, the issues it's that I can't put inside this sub all the three-component. After all, it tells me that the windows form button cannot be a textbox, etc. Do I need to put another two event handlers for textbox and Combobox? (The code below it's a workaround, but I Like to do this with a button)

Public Sub btn_Click(sender As System.Object, ByVal e As System.EventArgs)
        'Dim btn As New Button
        'btn = CType(sender, Button)
        'Dim txt As New TextBox
        'txt = CType(sender, TextBox)
        Dim cbx As New ComboBox
        cbx = CType(sender, ComboBox)
        TextBox4.Text += cbx.SelectedItem.ToString & vbCrLf
    End Sub

Lumotive Helps to Advance Lidar 2.0 via Open API

Lumotive, a company dedicated to the development of solid-state lidar systems which are used in the computer vision industries, has announced a new API that is intended to unify hardware and software integration of lidar systems. The company is hoping this new open API will develop into an industry standard.

Community AMA: Bryan Finster and Continuous Delivery

Continuous Delivery isn’t about how fast you can deliver, it’s about the outcome your delivery achieves. Bryan Finster, author of the 5-minute DevOps series and founder of the DevOps Dojo, joined our Dev Interrupted Discord community to answer your questions about outcome-based development, continuous delivery, and why failing small is better than failing fast. 

Bryan is currently a Distinguished Engineer at Defense Unicorns but has also worked for Walmart as a systems analyst and eventually became a staff software engineer for Walmart Labs. He had previously appeared on the Dev Interrupted Podcast to further talk about these subjects as well as the most common pitfalls dev teams find when trying to optimize their delivery process. Listen to the episode here:

A New Container Query Polyfill That Just Works

There is now a polyfill for Container Queries that behaves as perfectly as a polyfill should:

  1. You conditionally load it when you detect the browser doesn’t support Container Queries.
  2. You write CSS as you normally would, including current-spec-compliant Container Queries syntax code.
  3. It just works.

It’s pretty great to have a container query polyfill that is this easy to use and from Chrome itself, the first-movers as far as early test implementations. Looks like Surma put it together — thanks Surma!

There was a Container Query polyfill from Jonathan Neal called cqfill that predates this. I’m not sure if it’s officially deprecated, but it required extra non-spec CSS to work and PostCSS processing, so I’d consider it deprecated in favor of this newer polyfill.

Loading the polyfill is like this:

// Support Test
const supportsContainerQueries = "container" in document.documentElement.style;

// Conditional Import
if (!supportsContainerQueries) {
  import("https://cdn.skypack.dev/container-query-polyfill");
}

You can pull it from npm or use as a <script>, but this way seems best to me to keep things light and easy.

Then you’re free to use the syntax for a container query in CSS. Say you have a weather widget in HTML. You’ll need an extra wrapper element for your queries. That’s just the rule: you can’t query the thing you style.

<div class="weather-wrap">
  <dl class="weather">
    <div>
      <dt>Sunday</dt>
      <dd>
        <b>26°</b> 7°
      </dd>
    </div>
    <div>
      <dt>Monday</dt>
      <dd>
        <b>34°</b> 11°
      </dd>
    </div>
    <!-- etc -->
  </dl>
</div>

The wrapper is instantiated as a container:

.weather-wrap {
  container: inline-size / weather-wrapper;
  /* Shorthand for: */
  /* container-type: inline-size; */
  /* container-name: weather-wrapper; */

  /* For quick testing, do this to get a resize handle on desktop: */
  /* resize: both; */
  /* overflow: hidden; */
}

Then you write any global styling for that component, as well as container query scoped styles:

.weather {
  display: flex;
}
@container weather-wrapper size(max-width: 700px) {
  .weather {
    flex-direction: column;
  }
}

Container Queries polyfill example

Here’s that slightly more fleshed-out demo of the Container Query polyfill using an actual weather widget:

I first saw this over on Bramus’ blog, and he’s got a classic card demo going with this Container Query polyfill. Scroll up and down. You’ll see a row of bear cards at the top (if your browser window is wide enough), and then similar bear cards in different layout positions below that change into nicer formats when they can, based on the container query.

Container Query polyfill browser support

The polyfill docs say:

The polyfill relies on ResizeObserverMutationObserver and :is(). Therefore, it should work in all modern browsers, specifically Chrome/Edge 88+, Firefox 78+ and Safari 14+.

There are all sorts of other minor little caveats covered in those docs, including what it does and doesn’t support. Seems like mostly niche stuff to me — the main/typical use cases are covered.

A game changer?

As I write, we’ve seen behind-flag support for Container Queries in Chrome, and it is an official spec draft now:

That’s extremely exciting and points heavily toward browsers actually shipping with Container Queries, even if the syntax changes a bit on the way (it already has a number of times). But, of course, we have no idea if/when Container Queries do ship — and when that magical threshold is crossed, we also don’t know where we can use them without much worry, like we can with flexbox and grid now.

That “just use it” date is probably a decent ways off, but if you’re into the idea of polyfilling and being careful with progressive enhancement, I’d say the date for using Container Queries could be right now-ish. Looks to me like the polyfill script comes across the wire at 2.8kb, so it’s fairly trivial in size for something so important.

I suspect this polyfill will skyrocket usage of Container Queries in this coming year.

FOUC?

The fact that your styles only correctly apply after a JavaScript file is downloaded and executed puts sites into Flash of Unstyled Content (FOUC) territory. Here’s a video recording where I can see it on my own demo. I’m not sure there is a way around this other than intentionally delaying rendering, which is generally considered a no-no. Similar to loading web fonts, FOUC is probably a good thing as it means your content is never hidden or delayed, even if the shifts aren’t ideal. The FOUC should go away once browser support lands and the polyfill stops loading at all.

Have fun polyfilling container queries! I’d love to see more demos of it.

GitHub Repo for the Container Query Polyfill


A New Container Query Polyfill That Just Works originally published on CSS-Tricks. You should get the newsletter and become a supporter.

Database Tip: Clean Up User-Agent Data

I just finished up my latest book, Wizard’s SQL Recipes for WordPress. And it’s packed with over 300 time-saving code snippets for managing and optimizing your WordPress database. For example, one of the recipes from the book shows how to delete unwanted user-agent data from the WP comments table. This is an easy optimization step that can help to free up some precious disk space.

Check out the Demo/Table of Contents for Wizard’s SQL Recipes for WordPress.

Show all user-agent data

Did you know that WordPress collects the visitor’s user-agent data for every comment? In the database, user-agent data is stored in the comments table in the comment_agent column. But you would never know it because WordPress does not display the collected user-agent data anywhere in the Admin Area. No worries for us though. A simple SQL query will summon the information:

SELECT comment_ID, comment_author, comment_agent 
FROM wp_comments;

If comments have ever been enabled on your site, that simple query may return some surprising results. Or if you’re using an application like phpMyAdmin to manage your database, you can check out all of the user-agent data by visiting the wp_comments table and examining the comment_agent column. To give you a better idea, here is an example of a typical user agent:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36

Most comments should have some sort of user agent recorded, although some may not. It depends entirely on the client that the visitor was using when leaving the comment. Incidentally, any collected user-agent data can be used to identify which browsers/clients people (and bots) are using to visit your site.

Tip: WhatIsMyBrowser.com provides an excellent tool for identifying user agents.

In general, user agents can vary greatly. Some user agents consist of a small number of characters, while many others (like the previous example) consist of many characters. Either way, depending on the number of comments, user-agent data can consume a significant amount of space.

Delete all user-agent data

Before going further, if your site uses a plugin that makes use of user agents (remember, WordPress itself does not use user agents for anything), then stop right here. You don’t want to delete any user-agent data. But for everyone else — like probably around 99% of WordPress sites — all of that user-agent information is pretty much useless. So it gives us an excellent opportunity to clean up the database by deleting all user-agent information from the comments table. Here is the magic SQL recipe to do it:

UPDATE wp_comments SET comment_agent = '';

Here we replace the user-agent data with a blank/empty value for all comments in the WordPress database. If you would rather replace the data with n/a or any other string, replace '' with 'n/a' or whatever makes sense for your site.

Depending on the number of comments on your site, that simple query can reduce the size of the database considerably. And that’s a good thing.

Want more SQL recipes like this one? Check out Wizard’s SQL Recipes for WordPress — includes an entire chapter on optimizing the WP database!


WordCamp Birmingham Updates COVID-19 Protocols Amid Omicron Surge, WordCamp Europe Still Planning for In-Person Event

WordCamp organizers are responding to community concerns this week, as the more highly transmissible Omicron variant surges in many locations around the world. With WordCamp Birmingham less than a month away, the event’s COVID precautions came under greater scrutiny this week, as organizers work to adapt to the changing pandemic landscape.

Yesterday, the event’s masking policy stated “Masks are required for entry and preferred throughout the event,” setting off a heated conversation on Twitter.

WordCamp Birmingham has since updated its COVID-19 safety protocols to require masks inside the venue except when eating or drinking:

  • Stay at home if you feel even a tiny bit sick.
  • Temperature checks for entry on both days.
  • Masks will be required while inside our venue except when actively eating or drinking.

Attendees are also required to be vaccinated, or have recovered from COVID-19 within the last 3 months, or have recently tested negative. It doesn’t state any specific timeframe for having tested negative.

“Our original masking recommendations were published prior to Omicron really taking hold and were based on our local laws, local health regulations, our venue’s input, and direction from WordPress Community Support,” WordCamp Birmingham lead organizer Ryan Marks said. “Since Omicron has become more prevalent, we are monitoring the situation and have evolved our guidelines as a result.”

In what seemed to be an attempt to woo vaccine-hesitant Americans, the CDC removed indoor masking requirements for those who were fully vaccinated in May 2021, when vaccines were working well. Since that time, coronavirus variants have emerged that evade both vaccine and virus-induced immunity. However, many gatherings and indoor event organizers have been slow to change their COVID-19 protocols in response to the latest developments.

WordCamp Europe tweeted an update recognizing the recent discussions and changeable nature of the current threat, linking to a post on COVID planning from November 2021.

Nilo Velez, one of the lead organizers for WordCamp Seville, which took place in mid-December 2021, responded to WCEU organizers with some advice.

“I’ve been organizing in-person events during the last few months (including WordCamp Sevilla, with zero positives so far),” Velez said. “My top two take aways: 1) Airflow is your friend: plan for well-ventilated spaces and use CO2 meters on high people concentration areas.

“2) Enforce the use of face masks indoors, always. Enforce as in ‘Put a f*cking mask on or go home’ Excessive? State of the Word proves otherwise.”

Velez referenced the recent incident at the State of the Word 2021 event where attendees were not required to wear masks indoors. Multiple attendees reported infections following the event, which generated exposure notices for all in attendance. Attendees were left to make their own choices regarding indoor masking, and the resulting lack of masks was alarming to many onlookers as Omicron was spreading rapidly through New York City. Prospective attendees for future in-person WordCamps shared their reservations about the lax protocols on Twitter and said they are reconsidering WordCamps as a result.

“In my opinion, masks are not a choice but a must,” Velez told the Tavern. “In Seville, the precautions we took were simple:

  • Absolutely everyone was required to (correctly) wear a mask when indoors. That included, organizers, sponsors, staff… even the catering workers. The only exception were the speakers and only on stage.
  • No food or drinks were allowed indoors. If you wanted to have a coffee or smoke, you had to get outside
  • The WHO advises 11 square meters of air per person. We had only 100 attendees on a huge room to get 20 square meters per person.
  • We had a very short schedule, only 5 talks with long (outdoor) breaks every hour

Velez said his team had a streaming option for those who aren’t ready for in-person WordCamps and they were ready to switch to an entirely online event if necessary.

“We also have had three in-person meetups with no reported cases so far,” Velez said. “Weather helps a lot. Today at noon (5th of January) we were at 20ºC (68ºC). That allows you to stay indoors only during the talks and have all the social activities outside.”

WordCamp Birmingham attendees have posted about how excited they are to attend the event, no matter what the protocols, after two years away from their WordPress friends. On the other hand, there are others who hold the opinion that organizing any kind of in-person event at this time while, hospitals are becoming overwhelmed, is premature and irresponsible.

After speaking with WordCamp Europe’s lead organizers this morning, they are closely monitoring the situation and believe that a safe in-person event is still possible.

“WordCamp Seville was a successful and safe event,” co-organizer Bernhard Kau said. “Some of our organizers went there. Also, the Web Summit in Lisbon with more than 42,000 had excellent measures. Those are events we see as  examples.”

Organizers are eager to host the first in-person WordCamp Europe in three years but are willing to move to alternatives if new pandemic threats emerge in the next five months.

“At the moment our plan is to go for an in-person event but there will always be a plan B or C,” WCEU Public Relations team leader Evangelia Pappa said. “We wouldn’t want people to get in danger in any way. These people are our friends and family. They’re not just attendees or sponsors, speakers, volunteers. Keeping safe means also keeping our beloved safe when we get back home.”

Pappa said the team plans to follow all local regulations for in-person events with more than 1,000 attendees in a closed space. The regulations keep changing but for now they are requiring the following:

  1. Proof of vaccination AND proof of negative lab test is mandatory when entering Portugal
  2. Masks are compulsory to enter the venue or remain inside
  3. Maintain the basic guidelines (1.5 m distance, hand sanitizing, ventilate, face mask)

“Since we’re keeping constantly an eye on this, we may enforce other regulations on top of these, but it depends on the gravity of the situation,” Pappa said.

“Our aim is to get back to seeing our people, have a great in-person event, but when everyone goes back home, we’re all safe, our families are safe and we get to remember the WCEU 2022 as an amazing experience.”

WordPress’ Community Team has been discussing new ideas for supporting the safety of in-person events in 2022 and plans to share more in a blog post next week. One safety measure suggested is mandatory masks for all attendees (even in regions that do not have a mask mandate at this time). WordCamp Central has agreed to cover the budget for additional safety measures like free masks and hand sanitization stations. Contributors plan to engage this sensitive topic with a larger discussion next week.

How To Use SingleStore Pipelines With Kafka, Part 1 of 3

Abstract

In this article series, we'll look at a compelling feature of SingleStore called Pipelines. This enables vast quantities of data to be ingested, in parallel, into a SingleStore database. We'll also see an example of how we can use this feature in conjunction with Apache Kafka™. This first article will focus on uploading some data into SingleStore using Spark. In a previous article, we noted that Spark was great for ETL with SingleStore. We'll also perform some analysis of the data. In the example application, we will simulate some sensors distributed globally that generate temperature readings, and these readings will be ingested into SingleStore through the Confluent Cloud. We'll implement a Producer-Consumer model using Java and JDBC, and then simplify this using SingleStore Pipelines.

The SQL scripts, Java code, and notebook files used in this article series are available on GitHub. The notebook files are available in DBC, HTML, and iPython formats.

VB6 and Windows 11

In case you're wondering, VB6 programs run on Windows 11. Programs with a manifest have the appropriate Windows 11 appearance. The IDE works as well, although it seems to aggravate the known Windows 11 Taskbar flickering issue, but it settles down quickly.

The only issue I have found so far is that command button mnemonics do not appear after pressing the Alt key is you use a manifest. This can be solved by 1) not using a manifest file, or 2) changing the Windows setting to always show mnemonics.

Please note, I started with Windows 10 and upgraded to Windows 11. I assume an original Windows 11 install would work the same.

Best wishes to all.

How A.I. Can Transform Academics Into Immersive Learning Experiences

One of the biggest challenges facing today’s educational infrastructure is the inability of current technology to deliver quality courses to students. With the growing power of cloud computing and video conferencing, educational institutions have been keeping themselves in a “dark age” that only serves to inhibit student education and learning habits. 

If academia would turn its attention to cloud computing, artificial intelligence, and immersive learning beyond Blackboard and video conferencing solutions, it will enhance student learning in ways that speak to numerous learning patterns. 

Get array of a column value in array of objects in Angular 12

Hello i have an Angular 12 project and i want to retrieve all results in artisticBehaviour (except those who are NULL or same e.g. Actor, Actor) column in Users table.

ts function that i call all users from Users table.

allArtistsSet() {
    this.userData.allArtists(this.offset).pipe(
      map((data: any) => {
        if (data.success) {
            this.allArtists = data.artistsFeed;
 this.creativenessArtists = this.allArtists.filter((data) => data.artisticBehaviour != null);
        }
      })
    ).subscribe()
  }

html

<select style="background-color: #333;color: whitesmoke;padding: 5px;font-size: small; border-radius: 5px;width: 110px;">
                <option disabled>Creative Behaviour</option>
                <option>Creativeness</option>
                <option *ngFor="let creative of creativenessArtists" value="{{creative}}">{{creative}}</option>
                </select>

Does Tropica Casino pay out the most in Australia?

Table of Contents How to increase winnings utilizing Tropica Casino bonuses? Play games thay propose bonus rounds AUD Deposit and Withdrawal Methods Play where you want with mobile version Tropica Casino, fueled by the exclusive Rival software, brings a refreshing wave of novelty for Australian players. With a catalogue surpassing 100 games, Tropica offers an […]

Getting Started With AWS Amplify

Serverless cloud infrastructure is the next step in building apps. But if you’ve tried to navigate the vast number of services in the AWS console, you know that using the cloud is easier said than done. Today’s developers are overwhelmed with the amount of services AWS offers.

The solution? AWS Amplify, which helps developers to easily build and deploy complete mobile and web apps by providing a collection of CLI tools, libraries, frameworks, and cloud services.