teleren/devto huggingface dataset:
Careful with table partitioning in SQL
Tags: programming, database, picture
Published: 2022-09-06 12:15:29

---
title: Careful with table partitioning in SQL
published: true
date: 2022-09-06 12:14:30 UTC
tags: programming,database,picture
canonical_url: https://siderite.dev/blog/careful-with-table-partitioning-in-sql/
---

Original post at: https://siderite.dev/blog/careful-with-table-partitioning-in-sql

  I had this situation where I was trying to optimize a query. And after some investigation I've stumbled upon something strange: querying on the primary key was generating a lot of reads. I was joining my table with a temporary table of 10 ids and there were 630 reads! How come?

  At first I thought it was because the way indexes work. The primary key was comprised of RowId and RowDate and, even if I knew theoretically searching by RowId should use the primary key, the evidence was against me: when querying by RowId and RowDate I would get the expected 10 reads.

  I created two queries, one with and one without RowDate. I then compared their execution plans. They were identical! Only one took a lot longer, specifically in the Index Seek (which used correctly the primary key). When I looked at the properties for that plan element, I saw something strange:

![PartitionedIndexSeek.png](https://siderite.dev/Posts/files/PartitionedIndexSeek_637980632705857351.png)

Actual Partitions Accessed 1..63!

I then realized that the table was partitioned on the RowDate column. In this case, RowDate takes precedence to any indexed column! You might think of partitioning a table like forcefully adding the partition columns to every index in the table, including the primary key. In fact, a partitioned table acts like a number of separate tables with the same definition (columns, indexes, etc.), just different data. The indexes work on each separate partition. When you partition a table, you also partition its indexes.

In truth, I would have expected the query execution plan to show the partition split as a separate step. I understand it's hard to conceptualize it without creating as many execution paths as there are partitions, but still, there should be an indication in the shape of the plan that makes it clear you are querying on multiple partitions.

Once RowDate was used, the SQL engine would choose the one partition of my row, then use the primary key index to seek it. Instead of 63\*10 reads, just 10 reads, the number of the rows in the id table.

So be careful when you use table partitioning to ALWAYS use the partition columns in the queries for the table, else you will get as many parallel searches as there are partitions, regardless of the indexes you created, as they are also partitioned.

Hope that helps!
Playwright - Complete Beginner Course
Tags: playwright, javascript, webdev, testing
Published: 2022-09-06 12:11:51

Playwright is one of the newest and is becoming one of the most popular E2E test automation frameworks in the industry. 

Playwright is beginner-friendly, is supported with all the major browsers and can be used with multiple languages such as Typescript, Javascript, Python, Java and .NET. Best of all, it is free to use for anyone (startups to enterprise).

This course will take you from the very basics where I will teach you about what Playwright is and how to setup your first test with Playwright, to all the way to teaching how to build a fully functional framework. Along the way, I will teach you all the best practices that will put on the path of becoming one of the Top Automation Engineer. 

---

### Click the link below to get this course on a special launch discount (expires in 5 days) 🥳
https://www.udemy.com/course/playwright-complete-beginner-course/?couponCode=PW-2022-START

---

### Here's what we will be covering in this course:

- What is Playwright?
- Setting up your machine for perfect automation experience
- Installation & Setup
- Step by step guide on how to write tests
- Working with different types of elements
- Learning about how wait commands work
- How to use assertions & advantages of using them
- How to debug your tests when it fails
- Setting up a fully functional framework
- Page Object Model - What is it & how to set it up?
- Optimizing your framework
- Building beautiful reports
- Integrating tests with GitHub Actions
- And much more...

All of the topics are taught with real examples. The course will include exercises & quizzes that will challenge you & allow you to practice what you have learned.

This course will get constantly updated so that you no longer have to worry about any outdated content.

---

### Check out the Course Introduction video below - 
{% youtube 3lqJrwJJ-AM %}

---

Thanks for reading!
What is OpenAPI and how does it help REST API.
Tags: microservices, api, beginners, webdev
Published: 2022-09-06 12:03:42

Imagine it's your first day at work as a Software Developer working for an Investment Bank. 

It's your job to understand the bank's different systems and services. 
Now you don't understand the different REST APIs being used and what they do.

You also do not want to go through the whole codebase of these APIs.
**What will you do??**

You will refer to the _**OpenAPI document**_ to quickly understand what your REST APIs do.

> The OpenAPI Specification (OAS) is the universal standard to define and read RESTful APIs for humans as well as computers.

It helps you understand your API without having to read the source code or documentation.

The OpenAPI definition is typically a YAML/JSON file.

With an OpenAPI definition, you can describe the following things: 
1) Properties, Data types
2) Endpoints
3) Auth and many more..
It also helps in validating new APIs that are being built. 

An OpenAPI doc can be programmatically generated from your code using multiple tools like Swagger. 
It is often used to test APIs and generate client code.

Here is an example of an OpenAPI doc:

![OpenAPI specification example document](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8fpc0247m2lwr5pga75.png)


**Keywords used in the doc and what they mean:**

1. info : The info section contains API information: title, description (optional), version.
2. servers: specifies the API server and base URL.
3. paths: defines individual endpoints (paths) in your API, and the HTTP methods (operations) supported by these endpoints.
4. parameters: they are passed via URL path, query string, headers. You can define the parameter data types, format, whether they are required or optional, and other details.
5. requestBody: describes the body content and media type.

Hope you liked this short explainer. 
You can also find my threads on various backend concepts from the Web2 and Web3 world on [Twitter](https://twitter.com/BhosalePratim)
Do you wish to become a WordPress Developer?
Tags: wordpress, javascript, php, webdev
Published: 2022-09-06 11:59:01

Wordpress is a free and open-source content management system (CMS) that is used to create blogs, websites, and web applications.

![Image description](what does it mean to become a WordPress Developer)



Wordpress developers can work for various companies as freelancers or full-time employees. They can also start their own web development company that offers services such as designing, hosting, and maintaining websites.

The skillset required to become a Wordpress developer includes coding in PHP and JavaScript with an understanding of HTML5, CSS3, and jQuery.

Here are a few resources that'll guide you if you wish to become a WordPress Developer.

1. **FreeCodeCamp 1hr Course**:- [Learning Path for Newbies in WordPress Development](https://www.freecodecamp.org/news/learning-path-for-newbies-in-wordpress-development-a283981adf53/). 

2. LearnWebCode's 3hr Course:- [Becoming a WordPress Developer: Unlocking the Power of Code](https://www.youtube.com/watch?v=FVqzKAUsM68).
 
3. Web Monkey's 1hr Course:- [PHP Basics for WordPress](https://www.youtube.com/watch?v=mgGAvq9hmyU). 

4. DonTheDev's YouTube Video:- [How to Become a WordPress Developer in 2022](https://www.youtube.com/watch?v=A9gFloJrbfQ). 

I hope these resources help you kickstart your career as a WordPress Developer.

WordPress is a leading CMS platform that powers over 31% of all websites. The reason for its popularity is the ease of use and its affordability. WordPress developers are in high demand, but their salaries vary depending on the country they work in.

The average salary for a wordpress developer is $55,000 per year. However, this figure can vary from one country to another, depending on different factors such as cost of living and average salary across industries. In India, the average salary for a wordpress developer is $17,000 per year while it's $87,000 in Norway.

_This Content was written by [Ebuka Val](https://ebukaval.com/), he publishes content that helps WordPress users make the most from their site [Here](https://ebukaval.com/wordpress/)_
Best YouTube Channels for Front-end Developers in 2022
Published: 2022-09-06 11:44:07

I've put together a great list of YouTube channels for beginners, juniors, mid-levels and seniors. You’ll be sure to learn something new.

See the whole list: [https://dailydevlinks.com/best-youtube-channels-for-front-end-developers-2022/](https://dailydevlinks.com/best-youtube-channels-for-front-end-developers-2022/)
Create a Beautiful Datepicker Field in WordPress Admin
Tags: tutorial, adminpage, wordpress
Published: 2022-09-06 12:55:59

---
title: Create a Beautiful Datepicker Field in WordPress Admin
published: true
date: 2022-09-06 11:31:07 UTC
tags: Tutorial,Adminpage,WordPress
canonical_url: https://blog.kamalhosen.me/datepicker-field-in-wordpress-admin/
---

Adding a datepicker to a WordPress admin field is a great way to improve the user experience and make data entry more efficient. There are a few steps involved in setting this up, but the end result is worth it.

In this tutorial, I will show you how you can easily create a beautiful datepicker field just like on the screenshot below without any additional **JavaScript** libraries.

Let’s assume that you have a text field anywhere in WordPress admin. Just add `class="any-custom-class"` to it. Example:

```
<input type="text" class="my-datepicker" />
```

Now it is time to enqueue some CSS and JavaScript. You might say – “Wait, you’ve just told us that we are not going to use any JavaScript libraries!”. That’s true, but I meant additional libraries, but we can still use what is already **a part of WordPress Core**. It is jQuery UI.

```
add_action( 'admin_enqueue_scripts', 'khn_datepicker_css_and_js' );

function khn_datepicker_css_and_js() {
	wp_enqueue_script( 'jquery-ui-datepicker' );
	wp_enqueue_style( 'custom-css', get_stylesheet_directory_uri() . '/jquery-ui-datepicker-by-kamal.css' );
}
```

I’ve also added my own custom CSS for datepicker, you can find it on [GitHub gist](https://gist.github.com/ikamal7/0a458903d4d219064ac81549b10f7a3e).

<script src="https://gist.github.com/ikamal7/0a458903d4d219064ac81549b10f7a3e.js"></script>

The last but not least, let’s initialize datepicker for every input field with the CSS class my-datepicker.

```
jQuery( function( $ ) {
	$( '.my-datepicker' ).datepicker();
} );
```

If you’re looking for some customization, you can check [the official documentation](https://api.jqueryui.com/datepicker/).
Articles vs Videos - Which is Your Learning Preference?
Tags: discuss, programming, productivity, webdev
Published: 2022-09-06 11:30:03

![Hello Again](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rg3tvkg14kg6utoa2vn9.gif)

Some developers love learning through blog posts, articles, or just any form of written content. Others prefer finding videos, whether on Youtube or online courses, to learn about different programming topics.

Which is your preference when learning something new? It can also be a combination of both!

P.S: Look out for details about our latest release of [Medusa](https://github.com/medusajs/medusa) this week 👀
Before You Apply for a Job, Do This😎
Tags: productivity, career, tutorial, beginners
Published: 2022-09-06 11:21:12

The moment you apply for a job, have it at the back of your mind that you are competing with people who are better than you. It's advised that you prepare for an interview properly in order to beat your competitors. 

There are a few things you should do before applying for a job: 

1. **Learn about the company** - Understand the company's policies, criteria, services, and products. Doing research in advance shows that you are interested in the company and think of ways to make it run more successfully or efficiently as required. It's also essential to know a bit about their background history. 

2. **Stay positive** - Positivity will encourage you to carry on with your search. Additionally, your optimistic outlook will show during interviews and networking opportunities, enhancing your chances of creating a favorable first impression. If you don't believe in yourself, nobody will. 

3. **Update your Resume** - An updated resume will give recruiters a bad impression about you. Your resume should constantly highlight your most recent accomplishments, skills, qualities, and work experiences. It's crucial to check your resume for out-of-date information and update each part as appropriate before applying for new positions. Remember, how you present your resume determines the closer you are to getting the job.

4. **Clean your social media profiles** - Your social media profiles, such as your LinkedIn profile, may be viewed by potential employers when you submit a job application. Make sure your social media profiles reflect what you want employers to see when you apply for the job. This means you should remove anything from Twitter or Facebook that you wouldn't want a potential employer to see and update your LinkedIn page with your most recent experience.

5. **Read the instructions** - Carefully read the application instructions. Don't send a resume as a **.doc** file if the application requests one in **PDF** format. Don't send a resume if a cover letter is required. You almost certainly won't get the interview if you don't read every detail and pay close attention to the directions.




I hope you find this helpful.❤️

Got questions? Send me a message.
LinearSearch Golang
Tags: go
Published: 2022-09-06 11:03:41

```
package main

import (
	"fmt"
	"strconv"
)

func LinearSearch(a []int, k int) string {
	i := 0
	for i < len(a) {
		if a[i] == k {
			return "Found" + " index is " + strconv.Itoa(i)
		}
		i += 1
	}
	return "Not found index"

}

func main() {
	a := []int{10, 20, 30, 40, 50}
	fmt.Println(LinearSearch(a, 50))

}

```
System Design: SQL vs NoSQL databases
Tags: distributedsystems, architecture, tutorial
Published: 2022-09-06 10:59:40


In the world of databases, there are two main types of solutions, SQL (relational) and NoSQL (non-relational) databases. Both of them differ in the way they were built, the kind of information they store, and how they store it. Relational databases are structured and have predefined schemas while non-relational databases are unstructured, distributed, and have a dynamic schema.

## High-level differences

Here are some high-level differences between SQL and NoSQL:

### Storage

SQL stores data in tables, where each row represents an entity and each column represents a data point about that entity.

NoSQL databases have different data storage models such as key-value, graph, document, etc.

### Schema

In SQL, each record conforms to a fixed schema, meaning the columns must be decided and chosen before data entry and each row must have data for each column. The schema can be altered later, but it involves modifying the database using migrations.

Whereas in NoSQL, schemas are dynamic. Columns can be added on the fly, and each _row_ (or equivalent) doesn't have to contain data for each _column_.

### Querying

SQL databases use SQL (structured query language) for defining and manipulating the data, which is very powerful.

In a NoSQL database, queries are focused on a collection of documents. Different databases have different syntax for querying.

### Scalability

In most common situations, SQL databases are vertically scalable, which can get very expensive. It is possible to scale a relational database across multiple servers, but this is a challenging and time-consuming process.

On the other hand, NoSQL databases are horizontally scalable, meaning we can add more servers easily to our NoSQL database infrastructure to handle large traffic. Any cheap commodity hardware or cloud instances can host NoSQL databases, thus making it a lot more cost-effective than vertical scaling. A lot of NoSQL technologies also distribute data across servers automatically.

### Reliability

The vast majority of relational databases are ACID compliant. So, when it comes to data reliability and a safe guarantee of performing transactions, SQL databases are still the better bet.

Most of the NoSQL solutions sacrifice ACID compliance for performance and scalability.

## Reasons

As always we should always pick the technology that fits the requirements better. So, let's look at some reasons for picking SQL or NoSQL based database:

**For SQL**

- Structured data with strict schema
- Relational data
- Need for complex joins
- Transactions
- Lookups by index are very fast

**For NoSQL**

- Dynamic or flexible schema
- Non-relational data
- No need for complex joins
- Very data-intensive workload
- Very high throughput for IOPS


---

_This article is part of my open source [System Design Course](https://github.com/karanpratapsingh/system-design) available on Github._

{% github karanpratapsingh/system-design %}
System Design: SQL databases
Tags: distributedsystems, architecture, tutorial
Published: 2022-09-06 10:55:46


A SQL (or relational) database is a collection of data items with pre-defined relationships between them. These items are organized as a set of tables with columns and rows. Tables are used to hold information about the objects to be represented in the database. Each column in a table holds a certain kind of data and a field stores the actual value of an attribute. The rows in the table represent a collection of related values of one object or entity.

Each row in a table could be marked with a unique identifier called a primary key, and rows among multiple tables can be made related using foreign keys. This data can be accessed in many different ways without re-organizing the database tables themselves. SQL databases usually follow the [ACID consistency model](https://karanpratapsingh.com/courses/system-design/acid-and-base-consistency-models#acid).

## Materialized views

A materialized view is a pre-computed data set derived from a query specification and stored for later use. Because the data is pre-computed, querying a materialized view is faster than executing a query against the base table of the view. This performance difference can be significant when a query is run frequently or is sufficiently complex.

It also enables data subsetting and improves the performance of complex queries that run on large data sets which reduces network loads. There are other uses of materialized views, but they are mostly used for performance and replication.

## N+1 query problem

The N+1 query problem happens when the data access layer executes N additional SQL statements to fetch the same data that could have been retrieved when executing the primary SQL query. The larger the value of N, the more queries will be executed, the larger the performance impact.

This is commonly seen in GraphQL and ORM (Object-Relational Mapping) tools and can be addressed by optimizing the SQL query or using a dataloader that batches consecutive requests and makes a single data request under the hood.

## Advantages

Let's look at some advantages of using relational databases:

- Simple and accurate
- Accessibility
- Data consistency
- Flexibility

## Disadvantages

Below are the disadvantages of relational databases:

- Expensive to maintain
- Difficult schema evolution
- Performance hits (join, denormalization, etc.)
- Difficult to scale due to poor horizontal scalability

## Examples

Here are some commonly used relational databases:

- [PostgreSQL](https://www.postgresql.org)
- [MySQL](https://www.mysql.com)
- [MariaDB](https://mariadb.org)
- [Amazon Aurora](https://aws.amazon.com/rds/aurora)


---

_This article is part of my open source [System Design Course](https://github.com/karanpratapsingh/system-design) available on Github._

{% github karanpratapsingh/system-design %}
How Project Count uses Codesphere to make their deployment and hosting trivial
Published: 2022-09-09 08:10:38


---
title: How Project Count uses Codesphere to make their deployment and hosting trivial
published: true
date: 2022-09-06 09:59:20 UTC
canonical_url: 
---


> “With AWS, even just getting something setup that works is a huge pain and then platforms like Heroku are so inflexible with what you can and can’t install for your project. It just made sense to use Codesphere”


This past week we sat down with Simon Pfeiffer, Founder and CEO of Project Count. Project Count aims to make product carbon footprints easily accessible for everyone, so they can better understand how to reduce their footprint.

Before founding Project Count, Simon earned a Masters degree in Economics and worked at KPMG.

* * *

### The Technology Behind Project Count  

Project Count uses NLP and semantic similarity algorithms to map products on your shopping receipts with the product footprints in their database.

Simon uses a no-code solution to build and host the frontend of their service. They additionally launched an Android and iOS app for the German market, which can be found on their [homepage](https://de.project-count.com).

Project Count’s core software is on a python server that they use to configure, train, and use their learning models which estimate carbon footprints. Simon hosts this server on Codesphere.

![How Project Count uses Codesphere to make their deployment and hosting trivial](https://lh3.googleusercontent.com/huK6n1kA_wOu4JalzDdDmpQiMUpabcVC10JtjqLp2rltx6xPft5u_KfRg5Q8MJG9NbyzidkBs5ctDHJ6WZ7arhlWU_ziSDDCs7ZGfC7a1Fbxt0eIxzaqCscdUN-Sgyz1Rwq0nDK2FEwCFiljYS4a9w)

* * *

### How Simon Used Codesphere to Accelerate His Team’s Development Process  

The complexity of Project Count’s backend made cookie-cutter cloud solutions like Heroku extremely difficult to work with. Simon’s small development team was going to need to reorganize their backend just to host their app.

On the other end of the spectrum, hosting Project Count on a more robust cloud platform like AWS or GCP was going to require expertise and resources just to get a version of their backend running.

Simon found the solution in Codesphere. By having full access to their app’s VM, deploying their app was trivial. All his team needed to do was load in their repository, install their dependencies, and deploy directly from the terminal.

Codesphere has removed the unnecessary overhead, enabling Project Count to spend more time coding instead of taking more time in the configuration process.

Codesphere also enables Project Count to make ad-hoc changes to their code on cloud infrastructure, easily scale their servers, and even automate many of their devops processes.

To learn more about Codesphere, check us out at [https://codesphere.com](https://link.codesphere.com/TU)