So welcome to today's PostgreSQL Conference webinar, the NoSQL Store Everyone Ignored. We're joined by Zoheb Satya San, Senior Engineering Manager at DoorDash. We'll do a walkthrough of the history of HStore and how we can now use JSONB support and Postgres and discuss what makes it enticing and comparable to NoSQL stores like MongoDB or CouchDB. My name is Lindsay Hooper. I'm one of the Postgres Conference organizers and I'll be your moderator for this webinar. A little about your speaker. Zoheb is a dreamer hacker, philosopher, troublemaker. I want to know more about that one. An evangelist of open source who is also a long-term Postgres believer. Today, he's a technical lead at DoorDash leading the platform services team and using Postgres pretty heavily. Welcome. So with that, I'm going to hand it off. Take it away. Thank you for the introduction. See, it was better than I expected. So hello everyone. Welcome to the session. This is a fun little talk that I enjoy talking to people a lot about because I think fundamentally this whole feature set for Postgres has been kind of ignored over the time. And we've been looking at shiny tools around. It is definitely something that I believe it's worth looking into and might be useful for your knowledge set. So first, a little bit about me. I think I've been already given a big enough introduction, so I won't have you here too much. Here's my Twitter handle. You can follow me. I tweet tech stuff and the troublemaker stuff that was pointed out. Right now, I'm working at DoorDash. I have to say we use Postgres pretty heavily. It has been a remote tool. I've used, myself, have been a convert from MySQL to Postgres because for the longest time, like I was like a lamp stack guy who was using PSP and MySQL and all that, but it really opened my eyes the moment I kind of started looking into the feature set and the data types and I was like, this is amazing. Like, why are not people using it? And you can kind of see on Google Trends is pretty similar. Like the popularity of Postgres has gone up quite a lot.  So in 2009, Friend Feed published this blog post where how Friend Feed uses MySQL to store stimulus data. I was, again, going back to the context, I was, the MySQL, why I had to read this. Two years down the line when I started investigating into various things, I figured out it was one of the projects, if I remember correctly, where I had to store some stimulus stuff. I discovered Postgres and that along with this whole thing I discovered at Store. I obviously blogged about it. That here's my post from December 2011, where I first time covered the key value store everyone ignored. And this is exactly the hence the title of the talk. I'm kind of continuing on that, you know, marching on this whole topic. In 2012, I kind of did a reimagination of what if Friend Feed did what it was trying to do with MySQL and the limitations and all the stuff. I'll go to the details of this. So I won't spend more time over here. But I kind of reimagined the whole thing in 2012. And by that time, obviously, I had tried Postgres with a store and deployed it in production, tried it out and it worked out pretty well for me. Sort of continuing on that in 2015. So after that point for the longest time, I was disconnected because I didn't I didn't have the same need or the same problem that I wanted to use it for again. But way down in the line when I look back in 2015, somebody did talk with same title in Dublin. I don't want to butcher the last name, which by Stephen. So you can go check it out. It has some good material in there. So for our roadmap today, what I'm going to do is I'm going to give you a brief look at the Friend Feed use case with warming up on its door and the history. Essentially, when I would do that store thing, you would see I have essentially solved the problem that Friend Feed was trying to solve with the amount of code and the complexity that they had to deal with. But then I would take it to a higher level with JSON B, which is the modern incarnation of storing semi-structured or schema-less data in Postgres. And give you some examples of complex queries and how we would partition our documents because Postgres now has built in partition. So basically, I'm going to show you how this is not just a side feature, but it is essentially the core and how you can marry it with other features of Postgres and do some pretty amazing and awesome stuff. So Postgres is always evolving. At least for my 10 years, 12 years that I've been looking at Postgres, the whole storage engine, data wrappers, partitions, different data types, that was the first thing that brought me into Postgres itself. So from robust schema-less types from array, getStore, XML, JSON and JSON B to the core support on saying, okay, here's how you can do partitions. Here's improved data wrappers and storage engines. Postgres has just evolved over time. And that's going to be the story going forward. So two years from now or three years from now, if you're looking at this talk, keep in mind things might have changed because it's always evolving and it's always getting better. So let's do a brief history of ItStore because I want to do this because I think it's important to understand the story and the timeline in this whole universe of improvements that Postgres has brought to the table. So May 2003, first version of ItStore, that it was committed in and that was I think the movement where it was conceived. So if you want to look at the timeline of ItStore, it was first committed or it got in for Postgres Android 3, it was unpublished. 2006, ItStore was part of Postgres 8.2. 2007, generalizing new data indexes and just support Postgres 8.3 improvements in Postgres 9. And in 2013, somebody did some work for Nested ItStore with Erase port. So essentially enabling the document or the schema-free document support. Let's stay tuned for this because I'm going to talk about this later on. This almost became ItStore 2 and how it kind of merged into something just to give it a spoiler. Benefits of ItStore, it provides you a flexible model for storing a semi-structured data in Postgres. It is binary presented, so extremely fast, selecting fields of properties is really quick. It supports the JN and JIST indices. The only drawback that I can point out here is it's just too flat for my taste, I would say. Because it's basically a Q-value story. It doesn't support nesting or tree structures as you can think of in JSON. And JSON was introduced in 2006, three years later after ItStore. So how does it work? What's the data type? Let's kind of start building some context for that. So enough theory. Let's build something serious. Let's take the same friend feed example using SQL to build no SQL. So first I'm going to give you a walkthrough of what was the problem? How was it done when friend feed did it? It's kind of a brief summary. I won't be going pretty deep, but I would kind of show you the code patterns and all that. I would still recommend going to the original blog post here and go read through it. It was a mind-opener for me at least, I would say. Back in the days, it was a mind-opener for me. So why friend feed? Because it's a good example for understanding available technology and problem at hand. And I want to emphasize this, that people kind of cave into buzzwords when they're selecting stores or something new for solving a new kind of problem, which they think it's a brilliant idea. Well, sometimes it is, sometimes it's not. I feel like a good engineering. Take any big company. They don't master on creating new technology right away. They first master on solving the problem with the tools that they really understand because then you can focus on solving the problem. And later on, they can improve tools like, I can throw in some examples like Facebook's PHP and hip hop, VM and all that. So don't cave into buzzwords. That's my essential message. Same is true here. Friend feed didn't cave into the buzzwords and they started using, didn't start using less reliable or new tools, new kid on the blog. Also, I feel like friend feed was large enough at the scale to show you how you can, if you want to scale a problem with solving the NoSQL inside SQL, how you can do that actually. So again, using the tools you're comfortable with, read the blog post. Let's quickly move on. As part of that blog post, you won't, I pasted this image here from Wayback Machine because this image is broken there, but essentially what they claimed was by moving over to the steam of this mechanism and their new architecture, their latencies. You can see on the top graph where he says one week ago, the P99 latencies were down way below well contained and pretty stable. This is obviously one of the things that developers are always looking for when we're developing these large scale systems. We don't just have to focus on the means, but at the large scales we have to focus on the P99s or the edge cases where the worst cases. So with that in mind, let me quickly show you some schema for how friend feed, what a friend feed document. So every time I'm going to show you stuff in JSON format, you can imagine it in whatever format you want, but I would recommend you sticking to JSON. But I'll show you what a document looks like. A document is one object that you can think of that you're dealing with a single entity. So here is a post object for friend feed. Let me quickly walk through this. You have fields like ID, user ID, title, link, published and updated. And these are published, updated are like timestamps. So they are like units, timestamps, numbers. The rest of them are strengths, the key value stores that are strengths. What friend feed did was they created a table for entities, for these entities, where they have the similar schema except they have this blob in the middle. So for entities when they're storing it, they're storing this blob in the middle. This is where the whole JSON is going to be dumped as is into the body. So later on when you're fetching it by ID, the bodies are going to contain the whole JSON as is. And that can be shipped down the wire and the friend can pick it up and render the feed. So now the question becomes, how can we index? So in the same document, I'm just taking one field as an example here. In the same document, you can see there's a user ID field here that I want to index. How can you do that? So friend feed created a whole framework around it in order to make sure they can index these kind of fields. So here's how they did the indexing. So they said, okay, so for indexing, create table for each field. So essentially what this essentially means that for indexing user ID, they're creating an index table for user ID, where they have a user ID as, well, however you might like, a binary key and the entity ID pair in there. And I have the background workers populate the newly created index. And then you can also do stuff like, hey, I can do a background right into this table as I'm inserting rows. So essentially what this means is whenever you're inserting a document, there's some additional work that you have to do in order to insert into this table to keep it consistent with the view of the original entity table. So, but I've written the query below. The same example table that they posted in the blog post index user ID, user ID is the binary entity ID is the reference to the entity ID back into the original table. Primary key is the pair of user ID and the entity ID.  So obviously, in order to do that frictionlessly in code, they have to put in a lot of code to make sure whenever you're inserting a row into the table, then you're inserting a row into this table. And when you're ever, you're doing a lookup, you do appropriate reverse lookups. So here's an example of piece of code that I literally picked up from the poster game on them describing how they did that. So you can see they had the whole client side there has the sense or the knowledge of, hey, these are the shards. This is more complex in terms of configuration on the top because it's doing sharding as well, but let's even ignore the sharding part. Right at the bottom, you can see whenever they're doing a lookup, the whole lookup mechanism is subtracted away into this language. In their case, it was Python, so it's subtracted away into this Python framework that they created. But essentially, the whole responsibility or the load is handed off to the creator of the table and the index to kind of take care of it and make sure you're doing it on your side. So at a key value store, everyone ignore, this is where I'm going to start. Raise of hands, how many people or do a plus one or a lay of hands, how many people have actually used it store in past? Nice. I see some raised hands here. Awesome. For those who have not done it, go check it out. I'm going to be touching it a little bit on syntax, but I won't go into much details. So again, you can see it goes back 15 years, 15 years back. This is even before MongoDB, I think it was 2009 or 2006, I don't know. I might be messing updates where they actually first got in, but you can kind of see how far back this goes. This is almost in the age of axiomals and soaps and we're transitioning into that. So let's solve the same problem for, in fact, before solving the same problem, let's just create the same feed. And let's look at how it's going to look from the syntax perspective. So here's a simple create table feed with ID, where care and document it store. That's it. For some versions of Postgres, the older versions, you would have to execute the create extension in store command, but that should be more than enough once it's configured and it's done. And that should be it for having a table with ID and the document, the schema free document that you're looking for. So how do I insert or into this row? Pretty simple, insert into feed values, just like anything else that you would do, the random ID and the one at the bottom ID equal arrow to the values or ability and post equal arrow to hello as at store. And that's it. Postgres is actually going to store this as an at store value in there.  Like I stored it, I can fetch it back. What's the point? Well, the point is you can do complex queries like this now. So what I'm doing here is I'm saying select doc and out of that doc, select the post field as post. And as an example, I selected something undefined as well, undefined field. So just to show you it would be null from feed where doc ID equals so ability just to kind of get your feet wet. So essentially, I've already selected few fields from the document store itself and applied a filter on it. And this should be the moment of aha for anyone who is not used this before because you're traversing inside the column into the fields of this document. So however, if I do an explain on it, of course, it would be a sequential scan because there are no indices on it. And just like any good citizen of Postgres, you can create an index on it. So this is this is where I think once you do this, the whole problem, the whole framework that from feed built and people that has been solved, because essentially, you have an index on the field and you can store those documents in there without creating any troubles without creating any triggers or you know, background workers to fill do the backfills. This whole thing has been done for you out of the box. And of course, you can also say create a synchronous or create index index synchronously to create it in background. Well, if you discover, oh, there's a new field that I need to index. Think about it. If post, if friend feed folks were to do it in my SQL, they would have to create a whole schema. They would run whole, you know, background strips to backfill and everything. And just with this one statement, you've essentially removed all the engineering overhead and all the maintenance overhead and have a really clean index. Now you can do queries on it and you can actually run the explain and see who tell you like it is doing the index scan. But as I said, it doesn't end here. The whole system is the whole ecosystem is at your disposal. So over here, I'm creating a generalized search index over the whole document. So with gist, I can just say, okay, create an index on it using gist on the dot column. And now what you're going to do is something really amazing. You can actually, well, actually, you can do it even without this. But then again, they will be linear scans, but I'm kind of showing you the optimal way of doing it. You can do document matching, the key value field matching. So essentially what I'm saying here is select all the posts and the same undefined field that should be null from feed where document contains another document or the document matches this specification, which is another document. And over here, I'm saying ID is so ability. So essentially all the documents that contain ID so ability, they're going to be matched against it. And the result set is going to be returned back to you. So let's reimagine friendly, their whole thing, all that they did. Same entities table. I've just moved over to Postgres data types, updated timestamp and so on and so forth. The body goes to a store. The user index that they used to create for mapping everything into a table, that becomes a simple background, create an index concurrently on entity ID on this. And voila, you're done. You can essentially, you can essentially look it up by the, well, in this case, entity ID, but you can do the same thing with user ID. And there are more operators here. Like what I've showed you is just the tip of the iceberg. Here is just a snapshot of the operators. Of course, you can do selection with the arrow operator. You can get the, you can select multiple fields in single arrow, right? You can concatenate those to its store documents. This is just like a JSON merge if you've done it. The new fields would be added and the previous one would be replaced from the document on the right.  So essentially, you can take an existing document, add something new to it and update the document. The contains key and two or third down at arrow is, does the left operand contains right? The one that we used with our just index and vice versa. Like you can remove fields, you can, you know, convert it to array, delete operands, all that. And again, go to the link. You will love it. It lets you almost manipulate all of the document with these basic operators. But this is where we don't want to stop, you know. The next big thing that came in, well, essentially the next big thing that came in initially was JSON did attack itself. But it had its own caveats, including it was not parsed, it was not stored really optimized in the storage level. So every time you were selecting something out of a JSON document, it would parse the whole document. I think I have links to the slide where there were PRs and discussions around supporting nesting of documents inside a store. We almost had an ItStore 2 at that point in time because people really badly wanted ItStore 2, sorry, nested documents and ItStore was just a flat key value store. At that point in time, people thought about, hey, JSON is great. It's really well understood, standard people understand it. Why can't we combine the storage optimizations of ItStore with JSON? And that's where JSON B for real deal came in because it was binary serialized and all optimized. So again, coming back from the same story, why JSON? Well understood, go to standard for almost everything on web. It's self-describing and hierarchical form and serialization libraries for every programming languages are out there. You can see ItStore would require each language or driver to support serialization system. Let's you describe new shape of object which might be necessary in some cases. And though some cases, I can throw out some examples, but limit is your imagination like analytics through the workloads where, for example, the input structure that's coming in, it might have some fields, it might be missing some fields. So you don't need to have that sparse table where so many things are known. Similarly, if you're, for example, aggregating things from multiple places where JSON is coming in and it's totally different for, say, coming from Google and totally different, say, coming from Facebook. So you don't have to bind your table to these schemas. And what I'm going to do is, in order to kind of demonstrate how nesting can be useful or how powerful it can be, I'm going to take example of tweets and hopefully everybody understands Twitter here. So if you look at a Twitter JSON document, it looks something like this. It has an ID, it has some text, then it has a user object. And inside user object, it has your user information. Then there are nested object called entities, which has your tags and all that stuff. We'll do some operations on that in some time. And then it has these other timestamps and retweeted, truncated, so on and so forth. So taking the same structure for feed, you can have a similar structure here. And by the way, this is an extreme example, but still, for sake of simplicity, I'm keeping it on two columns. You can have more columns if you want. The fields that you think are always part of structure, you can definitely have them just like I did it with ID over here. So I created a tweet table with contents and JSONB column. Now I can insert in a similar fashion, where I can say ID is here, and the whole string of JSON dumped as is from anything that's realized. I'm not going to put an example here, but you can always imagine just doing an insert statement, a basic insert statement that inserts those documents. So now how do I select fields out of it? It looks extremely similar to what you saw in its store. Content, the same arrow operator, text, STXD, and then I selected favorite count, SCNT. So in this example, I'm just picking text and favorite count. From tweets where content ID, STR, ID, STR is ID in string format, and I'm just putting it in the ID. And yes, you can index this as well. So essentially, you can create an index similar to you did it for its store. And that should be good enough, right? So you should be able to do almost whatever you want from the structure of the document. So picking into structure, if you want to look at the values, there are multiple operators here. And I'm going to go with assumption that you can go to the docs and read about these operators. A lot of these operators look very similar. In fact, they're exactly similar to what you saw in its store. So I'm just building on the assumption of your knowledge from its store. Over here, I'm paying our favorite count. I'm selecting all tweets where content favorite count is greater than equal to one. So again, like I'm picking another field and just saying, treat it as an integer, and if the count is better than one, select everything over there. But yeah, if I'm going to explain this without the indexes, you can always imagine it's a sequential scan, which is bad. You should not do that in production. But again, I can create an index on this. So here is an index.  Here's an index. Again, I created an index on saying, hey, content favorite count as an integer, trade an index on this. Now, if I select it, you can see it's a bitmap scan. It's optimized as you expect it's going to be done from postgres. So now you can imagine the JSON for friend feed being stored in here and you're doing queries and everything in this one basic table. And all you need is indices. And now you're actually JSON compliant as well. But let's do some more JSON widgets, I would say. So I remember I told you inside entities, they're hashtags. So what I want to do is I want to build something that can do a lookup on hashtags. So hashtags is usually an array of objects that has a text to the value. It also has some additional information like indices that indicates from what index to start of what index to end of what index, this tag has been applied. So Python, hash, Python, hashtag, Python, it would automatically put that information here. But I'm not interested in that. That's the beauty of this thing. So what I'm writing now is a little bit more advanced query in terms of what I can select or what I can pull out of this whole document. So now what I'm doing is select content hash. So this particular operator hash, it's going to let me select multiple fields or select paths. I can walk paths with this operator. And I'll show you in an example next on the table next, what does it mean? So essentially what I'm saying is from content, go walk up to text and select that as a text. From tweets, where content, inside content, go to entities and then hashtags. So it's essentially saying like if you were thinking it in JS or JSON, document.entities.hashtags. So we're selecting all the from the array, all the documents or all the JSON objects of hashtags. And then I'm matching using the same ad operator that you saw before. That's a beauty of it, like the same reuse of the operator. Match all the documents or match all the array documents that have text, Python in this. And this is going to return me back all the tweets that have a tag of Python in there. So as for JSON operators, there are a lot of operators. We have already seen the error operator, the error with double tip on the top that's get element as text. The fancy operator that I showed you, the hash and the angle bracket, that's the one where I was saying get JSON object in the specified path. If you just do the double angle bracket, it's going to return you back the object as specified as text. And I won't recommend using it, but you should be sure about in this path if it's text or something. Similarly, exact same operator for matching ad. If the document on the left is the sub document on the right, the other way around, the field question mark operator for field containing. Similarly, the pipe operators for concatenating negative so on and so forth. Like this is all documented on the main documentation page of JSON media type. So you can kind of tinker with it. Really set of interesting set of operators. And you're going to be able to do quite a lot of stuff just with these operators. So let's do, we already did selecting text with matching text, but I didn't call it out before, but looking at the same example, let's repeat the example just one more time.  It's going to return me an array of documents. And then I'm saying if it's a subset of this array document of text to Python, then it's a match. And you're selecting everything. But you can imagine since I don't have any index on this, this is going to be slow. Right. It's going to be a sequential scan. So what if I want to create an index? The same greatness surrounds the same greatness that you had in net store surrounds JSONB. Over here I'm creating that index. This time I'm creating JIN index because I want an word index in this case. And with JSONB ops, that's the only change that you have to put in there for JSONB operators. So now, after creating the index, I can run more complex queries. So running the older query is going to be linear or index scan. But I can do more. I can say, oh, you know what, I just observed that a tweet can be a retweet. And the hash tags and the parent tweet doesn't have those tags. So I do want to look at the parent, sorry, the retweet itself. And inside there are hash tags. I want to surface them as well. Guess what? You don't have to do anything complex at all. Here is an example that I put right on the top. I create an index. I'm saying inside content, look at the retweeted status. And inside the retweeted status you would see entities and then hash tags and index that as well. So now at the bottom, the query at the bottom is combining both of them. So what I'm saying is select content from text, the select content text from tweets. I do look up on the entities hash tags of the document. And then I, or with content that's retweet status entities, hash tags status. So essentially retweeted status dot entities dot hash tags, attacks also contains the same text. Well, I don't know. I think it's a typo poster here. But you can imagine right there. So essentially I'm now selecting everything from a nested document, which is the same copy of the parent document. And that's not it. There's more to it. That's the beauty of this. So all that we have done so far is just, you know, run of the mill features that were provided along with these new operators. But now the beautiful part of this thing is now you can combine JSONB with the whole ecosystem of the Postgres. So you can think of all the features. And that's what I'm going to do. This is think of this as kind of showing off to other folks on saying, hey, yeah, you can do this as well. So here is an example. JSONB and full text searching. So for example, I want to do a full text search on the text content itself. So I'm trying to build kind of I'm kind of digging into if I'm building a search engine on top of these tweets. This is where I'm heading. So here on the top you can see I created a gin index on the text vectors in English. So the first parameter is English. I'm assuming the tweets are English. Of course they're not. But let's for sake of simplicity, let's go with this. So pick up the content text and that becomes that gets converted into the vectors. And then I am doing an inverted index on top of it. And there you go. I have a full text search engine. Now I can say select content text where I'm matching ps2 vector of for English text content to query SDR in English and I'm saying Python. So all of search all of the text that in tweets that contains Python. And I think Python, if you think about Python, it's more basic, but you can think of more free form text query searches that you can do on top of this. And you have to remember all of this data is sitting inside a column that has been serialized and saved on this for you in a structure feed format. So all the all the documents that don't contain the text field would automatically be more because they're not. Is that it? I don't think so. Let's do one more good thing here. So I can use this with partitioning feature of Postgres. So it's a new latest and the greatest stuff from Postgres. So what I've done is I've created a table right on the top. I've created a table part tweets just for partition tweets content. And then I'm telling it partitioned by hash of MD5 of content of user ID. So I took a random, well, I just picked content user ID. So inside, remember inside our tweet, we have the user object. So what I'm trying here to do here is I'm trying to partition my documents by user ID. So for a same user, all the documents of that user lie on the same partition. It could be anything else for you. Like you can even partition it by ID or something else, whatever you might think of, even from within the document, doesn't matter. This is just an example. And then you can see at the bottom, I have a create table part tweets 0, 1, 2, 3. And each one of them is a partition of part tweets. The important thing to remember is the hash and the MD5. And I think anybody who has done missing charting knows how to do partition with consistent hashing over the tables. So essentially what I'm doing is by doing an MD5, I get a number and I do a hash on top. By doing MD5 of the user ID, I'm essentially rotating between one of these partitions when the remainder is either 0, 1, 2, or 3. So if your ID is, say, 10, I do a modern list with 4, so the remainder is 2. So you're bound to fall on part tweets to partition. And then I can repeat, rinse and repeat. Now creating same index on the part tweets. Now here's the beautiful part. The tables are partitioned and now I'm creating an index on the top level table. The same indices that I created and I insert into parent table. I'm not looking into the partition tables itself. And with these indices, here's a beautiful part. Now I do a query on part tweets. And you can see when I did the query on tweets for saying, hey, pull out everything that has Postgres tags on it. You can see it automatically distributed, Postgres automatically distributed in among the tables, doing bitmap scan and then pending the results together. And doing it on even more complex queries, you can see it still does a pretty optimized version of bitmap or and then bitmap indexing on each one of them for each of the lookups that you did and the whole thing has been solved for you. This is all without writing any client set code. This is all done for you just because the ecosystem of JSONB and partition indexing is working hand in hand. So the limit is your imagination.  I know there are still tendency to say, oh, yeah, this new tool is it. But if you just look at the feature sets that have been shipped in Postgres, I think they're pretty awesome. For links and resources, I am touching a bunch of links here, including my blog posts and some really important documentation slides and presentations around the topic. Thank you for your time. I'd like to open up the room for questions. Got to say that was a pretty fun presentation. So far, we only have one question, so go ahead and get those in now. So the first question came in only a few moments ago and it was why the MD5 part for the partition key? Oh, okay. So it's totally up to you. It's not required as such. What I would say is if your user ID generation is not sequential, then you won't need to probably worry about it. But what MD5 does is I took a very basic hash function that doesn't even distribution. So passing it through the MD5 function is going to make your documents spread more evenly across the partitions that you have. You don't necessarily need to do it because if the user ID is already an integer, yes, the mod would work. But you can imagine when it's sequential, then first partitions, there's going to be a skew of partitioning. MD5 makes it kind of more even. And it's totally up to you. It's totally dependent upon the ID generation mechanism. Wonderful. Sort of a follow up to that. Does partition by hash expect a value from a hash function such as MD5? Because that would explain it. Yeah. So essentially what hash function, when I was doing, if you remember at the bottom, I was doing a modulo with four, right? So imagine, okay, let me make it even more simple. Imagine if your field is not integer or a number. Imagine it's a string, right? So user ID, imagine if it's a UUID. And I think in case of Twitter, it is a number. But you can imagine if it's a UUID that you're generating. So yeah. Then the modulo partitioning mechanism where I'm specifying the criteria of what goes in this table actually requires that to be something that is ingestible. So it's totally dependent upon scenario. Don't take that seriously. Thank you. How is benchmark comparison on performance of Postgres JSON with Mongo excluding sharding options? Yeah. I've not seen official third party benchmarks, but one of the slices is one of the slides that I've included in the links. It has some benchmarks with its store and its store did beat it. So it was faster, but this still needs to be verified from third party. The problem with, I think what everybody forgets when they're comparing MongoDB and Postgres is like solid asset store. It's a full transactional asset store. It's not like any random dump it out. I know Mongo has made improvements, but I would recommend if you ever pick Mongo, first go look at the JSON benchmarks if that rings a bell. But even with that, the benchmarks are, I don't think they're comparable to be honest from asset perspective and all transactional perspectives, but even with all of that, the individual benchmarks show a higher score, but I won't take them seriously. If it's good enough and if its scales are not good enough, I would take that any day. Fantastic.  How is opinion on OLTP and OLab? Can we grow with the same Postgres with 25 plus terabytes? Yeah. I know there are various, okay. So when people usually are talking about these kind of workloads, I know there are flavors of Postgres that are optimized for like OLTP and analytics workflows and all that. I've personally seen Postgres work at a pretty, of course I cannot disclose the numbers, but a pretty large scale, more than what I thought Postgres can do. So yes, I think the whole thing that you have to remember is the foundational pieces remain exactly the same when you're looking up the columns and when you're doing these lookups, it's as good as when you had an index on a column and you were doing a lookup. So the foundational pieces remain the same. So if something was working on that particular index, it should work here as well. It is no different than a regular index that you've seen. Okay. So with that, we can actually call it. Thank you so, so, so much. This was a wonderful presentation. I have to say, I loved the font. We had a lot of fun with that. And for all of our attendees, thank you so much for joining us. Thanks for spending a little bit of your day with us. And I hope to see you on future Postgres conference webinars. Have a great rest of your day, whether it's morning or evening. Thank you. See ya.


We move now to Adamawa State, where the All Progressives Congress there has called on the electorates to get their permanent voter's cards PVCs ready to elect the party's candidate during the forthcoming general elections. APC's organizing secretary in Adamawa State, Mustafa Ribadu, made the call while celebrating the victory of Yula South Local Government Party executives at their appeal court. In Adamawa APC is, I think Yula South is the home of APC and every APC program start from here and most of the stakeholders of APC are from here. That's why we find it worthy to see that we sat down with all the ESCO to see how can we brainstorm, how can we work together as family members as APC faithfuls and we are ready to deliver APC from top to bottom and vice versa. That's why we are here and that's the ben of our discussion. We are ready to go for the APC and for all the other candidates. And we use that medium to congratulate our chairman, Honorable Bengal and his ESCO for victory at the court. As we know that the court is the last hope of the common man and the agreement of justice and we say thank you to the Nigerian judiciary system and we say thank you to all our APC supporters. Subscribe to our YouTube channel and don't forget to hit the notification button so you get notified about fresh news updates.


Over the centuries, Christian theologians and philosophers have offered a range of models for making sense of the data of Scripture. The Canotic models from the Greek Canosis meaning to empty, they interpret the Christ him and Philippians 2 as saying that the Eternal Son emptied himself of some divine attributes in order to become fully human. It doesn't make sense either. That's the argument that he is sometimes fully man and sometimes fully God but at the same time he is always fully man and fully God, right? But when he says about the last hour only the Father knows, well this when he is fully human and shows you his fully human side, just swapping back and forth. This doesn't make any sense whatsoever.


Boc, Boc, Boc, Boc, Boc. Hello? Are you there? It's me. This is a little strange, but I wanted to ask you, what is my purpose? Am I to be the first chicken to graduate from community college, the first chicken to win a starring role in a Broadway musical, the first chicken to fly, a plane, and an air show over Pasek, New Jersey, or is it your will that I dedicate my life to good deeds, like, I don't know, donating my tiny shampoos to charity? What is it you want of me? Please, I am your vessel. What do you have in store for me? Winner, winner, chicken dinner.  Sign up on the app and visit our new restaurant, Thursday and Friday only.


I am Dr. Richard Nigam, Consulted Physician, Manipal Hospital, Kharagpur. We celebrate World Health Day, 7th of April every year. This time I am going to share few details about vitamin and vitamin deficiencies. Recently, post-COVID, the importance of vitamin deficiency has largely been realized by a significant group of population. All of us have taken and have seen people taking vitamin supplements for their immunity-related benefits. Off late, through health checkups, people are realizing that they either have insufficient or have deficiency in their vitamin status. So, it is important to know that what are the subtle signs of vitamin deficiency and what all this can lead to if it goes unchecked. So, subtle signs like unexplained tingling and numbness, especially in peripheries like hands and feet, fatigability which is not explained in spite of taking good diets, states of mental confusion and poor memory, especially is responsible for some mental agony can happen in patients with vitamin B12 deficiency. Now, this vitamin deficiency, if it goes unchecked, can lead to issues with blood coagulability, can increase the tendency of formation of blood clots, can lead to issues like stroke. Also, subtle memory changes can eventually contribute to memory dysfunction as happens in case of say Alzheimer's disease. Also, vitamin B12 deficiency has been associated with spinal cord damages. So, it is important to incorporate vitamin rich diets on a daily basis as well as to identify the deficiency through appropriate blood testing. Some people do have borderline levels of vitamins, so we call that as insufficiency. These patients are specially liable to have vitamin deficiency related damage which goes unchecked. So, on this health day, I request that one should be trying and identifying his or her levels of vitamins, especially vitamins like vitamin B12, vitamin D, to gather a lot of health related information and to prevent unnecessary damage to the body. Thank you, wish you a very happy world health day.


Your coca-cola bottler presents Claudia based on the famous play and novels by Rose Franken Brought to you transcribed Monday through Friday by your friendly neighbor who bottles coca-cola Relax and while you're listening refresh yourself. Have a coke and now Claudia Here Out of here behind the barn. What do you want Claudia? Well, what do you want? Nothing.   Oh, I have that by the way, what do they call a bull for short bully? No darling. I really didn't want anything. I just wanted to know where you were and what you're doing You've been asking a lot of questions, but to answer the last one and not doing anything Well, don't overdo it.  I have to start treating me like a couple of nursemaids with an errant child Just pretend that I've grown up and know how to take care of myself. I'll pretend that you don't Don't what? Don't know how to take care of yourself.  It's no good of an idea. I look Claudia. I was in an automobile accident, but I'm all well I'm all patched up now.  It's not hard work And I am going to do it no matter what you say. I won't say anything But I think it's foolish. Oh Tell me one reason why you think it's foolish. Oh, let me see Because the wire doesn't need nailing up and have our cows how singular and yet to be I stand corrected You have our singular cow wandering all over the countryside no sir You were with me yesterday when we walked out here and looked at the places the wire is down You looked at the wire darling, but I looked at the look in your eye and And what and I told Fritz to mend the fence he fixed it yesterday afternoon. I Wish that Bobby could walk you've done it Done what out non sequitur'd me? That's the word isn't it? You're always saying that I say things that don't hang together and follow and make sense There's absolutely no connection between fixing a fence and Bobby walk. That's what you think If if Bobby could walk he could get himself into all kinds of wonderful trouble And you'd have your hands so full worrying about him. You wouldn't have any time for me. That's what you think always have David do we have any bears or wild animals? Come again, I'm not following you. I said do we have any bears or wild animals around here? I'm just asking a simple question a simple question out of the blue simple question out of those elder thickets on the hillside over there something moved Where I Don't see anything It's bigger than a rabbit or a woodchuck and it's not as big as a cow. So it must be a bear No, I don't see anything I Suppose you didn't hear anything. Yes, I heard something and that hunter is going to hear something from me David your nostrils are wide. I don't think it's why you don't think what's why dr. Barry doesn't want you to over exert and Whoever fired that shot has a gun and he's done his last shooting on this place. Hey Hey, you up there on the hill. Come over here. I want to talk to you city pot hunters shooting everything that moves Breaking down fences starting fires. When do I get him?  Where I don't see him. See just to the right of that thickest.   Don't blister him too hard David Just show him off the place and tell him he has to hunt someplace else.  Well, I'd say Jimmy mr. Norton and I don't want any shooting on this place We don't do any shooting and we don't want anyone else to do any shooting that is why we put out the no trespassing sign Trespassing Now that's a that's a pretty hard word for a boy to understand and I'll spell it out for him It means private property. It means stay out That's a pretty hard idea for a neighbor to understand But we own the land. It's ours. We pay taxes so we can that's what the deed says Claudia Norton and David Norton all that certain peace parcel attractive land To have and to hold and fees simple in language simple That's a lot of legal balder dad that it is It means we have certain rights, but honestly men make simple things so complicated It means we either own the land or we don't know what means that all right But I'm afraid that there are certain rights of others that the deed doesn't mention You see all the people who live about us they and their families have lived here for generations Mrs. Norton hello hunting Jimmy. Yeah Do you get anything? Well almost that's good. No, it would have been better if I'd hit him. I close my eyes I guess I got a bad habit of closing my eyes. I didn't exactly mean that when I said that's good I know what Mrs. Norton meant Jimmy was that it must have been a pretty good shot to almost get him But you didn't get him by the way, what was it that you almost got? Woodchuck. Woodchuck. I mean one of those funny little brown things that Looked like bears and sit up and hold its paws together and wiggles its nose and Falls backwards down its hole when you make a noise.  Sure are they raise all heck with new seeded fields The mr. One had a cow last year what stepped in one and broke his leg I mean her leg, but Jimmy mr. Norton and I haven't any cows yet David. Are you with me or against me? Oh, I'm standing on the sidelines. Well Anyway, a car has to take his chances her chances and we haven't got any new planted field yet Now what Mrs. Norton is trying to say Jimmy is that she didn't know woodchucks were so dangerous what I meant to say that's a That's a wonderful rifle. What is it? It's a Stevens a single-shot Stevens. It's all right That's great. If it was a repeater. I would have got that woodchuck Yeah, a lot of big games been shot with a single-shot rifle.  Norton. Well, they're the best kind who'd want a brand new gun guns like a pipe It isn't much good until it's been broken in gee you really know about guns.  What for what did you shoot mr. Norton? dear David, how could you have Mrs. Norton?  I guess women just really don't understand about Hunting do they mr. Norton? How many did you shoot just one? I I Didn't have to shoot anymore. Did you have to shoot that one? I thought I did I Guess that's part of the growing up a man has to do gee Did you ever shoot any really big game mr. Norton? No Come to think of it.  There ain't that kind of hunting around here. No Had to take a pretty long trip and it took us quite a while We were a long time coming back Those of us who did come back Gosh, I'd like to go on a real hunting trip like that. I hope you never have to Jimmy I hope you do all the hunting of your life on the fields and hills of Eastbrook Sometimes it's very necessary to There was a group of farmers who left their fields one summer afternoon and marched toward Concord They took their hunting rifles, but man don't have to kill there must be better way. They are Some day all men may use them, but until they do Look this country has never fought an unjust war and it's never lost one And they were fought not by professional soldiers, but by men who were willing to die that others might be free Men who had learned his kids even across these acres of ours How to handle the only weapons that can oppose the power of evil and oppression in the world This here gun was my dad's gun when he was growing up. Ma finally said I could use it She won't let me use his other guns though. My dad was a fine shot. He was in the army, you know Yes, I know He must have been a fine soldier Your dad must have been a fine man to Jimmy you've left you such a rich memory of love My dad was the best man there is He would have taken me hunting with him. He always said when I grew up he would He would have learned me all about shooting Closing your eyes when you pull the trigger That that isn't good is it? It's the worst thing there is Jimmy No, I have an idea that your father it's sort of like to think that When you went out hunting you knew how really knew how How am I going to learn? Jimmy, I have an idea that if you ask David He might take you out hunting tomorrow morning. Gee, Mrs. Norton.  Hi, Mr. King. Hi, Jimmy Hey, it wouldn't be that I saw you carrying that rifle across the Norton's fields. They just posted their land You know that doesn't apply to neighbors the Norton's ain't like city folks or summer people. There's a difference sure is The Norton's belong they're neighbors. That's a nice distinction and I think I get it By the way, did you get anything? Almost but I close my eyes But mr. Norton's gonna show me show me how to about shooting Him and I were going hunting tomorrow. Yeah, she wish I could go along Maybe I might But say what does Claudia think of your hunting? Oh, you know women at first. She didn't seem to like it so much And then she came around and said all right Women aren't so bad underneath and next to my mom. I guess Mrs. Norton's better than most a very profound observation Jimmy. Well, I'll be seeing you maybe tomorrow Now as I was about to say every day Monday through Friday Claudia comes to you transcribed with the best wishes of your friendly neighbor who bottles Coca-Cola So listen again tomorrow at the same time And now this is Joe King saying or a bar and remember Whoever you are, whatever you do, wherever you may be When you think of refreshment think of Coca-Cola For Coca-Cola makes any pause the pause that refreshes and ice-cold Coca-Cola is everywhere This broadcast of Claudia was supervised and directed by William Brown Maloney And now here's a word from your friendly neighbor who bottles Coca-Cola


Haliti down to his left, Pio Kirby on the right, he goes to Haliti, he gets outside, and then inside a wrist and lovely play! Labano-Haliti, one absolutely superb from Labano-Haliti. It's the build-up player as well, he's still got so much work to do when he receives that ball. Well-tracked while risen, cuts inside him, and Vandenbringes leaves him as well. The water finished, he just wraps his foot around that ball, looking for that far corner. Just gets a little bit of help off the post, Vukovic had no chance to get across to that, and it's a wonderful play from Wanderers. Top shelf!


Two electrically charged objects are brought near each other, and before they physically make contact, somehow each is aware of the other's presence. It's as if some unseen force reaches out through even empty space and makes contact between these two objects even before what we perceive as physical contact can occur. The physicist Michael Faraday hypothesized that just such an invisible field of force was present whenever net unbalanced electric charge was present, and we'll begin to explore that idea now. In this lecture I'm going to cover the basics of the electric field and give an example of electric fields from a very simple charge distribution, specifically the electric field of a single point charge and what it does to other point charges around it. The concept of a field of force is something to which you were introduced specifically in the context of gravity. Mass is the source of gravitation as a force. It can act on other masses at a distance with no physical contact, and the way that we describe how mass responds to the gravitational fields created by other masses is through the concept of a field of force. At every point in space there is a force vector that points in a predefined direction and that direction is given by the law of gravitation. Similarly, as we have now learned to describe the electric force using Coulomb's law, Coulomb's law is the central law that tells us how one point charge exerts a force on another point charge through the electric force. We can adapt that idea into the concept, which is a more general concept, of the electric field as the fundamental object and then charges responding to those fields. We're going to transition now much as one does in gravitation from the idea of the gravitational force to the gravitational field, from the idea of an electric force to an electric field. The field is more fundamental than the force. The force is the consequence of the presence of the field. The idea of using a field of force vectors to describe the action at a distance that we see in the electric phenomenon is really credited to a brilliant chemist and physicist named Michael Faraday. He lived from 1792 to 1867. He is one of the most important figures in the last 400 years, 500 years of physics as it developed as a fundamental science. He came from origins in English poverty. He was an Englishman by birth, but he was not wealthy. He did not come from a wealthy family. And as was common in the time, if one was not born into wealth, it was very difficult even with an education self-generated or otherwise to break into the scientific elite of England of the day. The elite largely were monied individuals and because of the class separation in England at the time, it was very difficult for somebody coming from poorer roots to imagine a successful career even though they may be brilliant, even though they may be motivated, it was very hard to break the ceiling of poverty and get into the scientific elite. But through his own persistence and his own genius and his own abilities, he was able to break into England's nobility controlled scientific elite and he did it first by basically being an assistant to a well-known scientist at the time. But through experiments that he conducted as that person's assistant, he began to distinguish himself as his own scientist and eventually not only rivaled the person that had mentored him while he was simply a laboratory assistant but surpassed his mentor in ability and reputation. And he introduced the concept that one can describe the spooky action at a distance of the electric force reaching out across space with no physical contact through the field concept. That is that you can picture tendrils of force stretching out in space and any charges that cross those tendrils will be subject to Coulomb's law, to the Coulombic force, the electric force. We can begin to explore the concept of the electric field by first appealing to what we have learned from Coulomb's law about the force between two charges. Let's begin by considering two elementary charges. So the elementary charge is a magnitude of charge in Coulomb's equal to 1.6 times 10 to the minus 19 Coulomb's. So let's imagine that we have two charges, one negative E and another one up here, positive E. And let's also imagine that the negative electric charge is fixed in space. It's not allowed to move. So we'll call that fixed in place. The positive electric charge, on the other hand, is free to move. And what we know from Coulomb's law, what we know from observing the electric phenomenon, is that charge exerts a force on other charge. And in this case, we have dissimilar charges, a negative charge and a positive charge. And so we expect to have an attractive force between them. Now, since the negative electric charge is not free to move, let's consider what happens to the positive electric charge. We can imagine the line of force that connects these two particles. We can draw it here, for instance, as an arrow, a vector. The vector points from the positive electric charge to the negative electric charge and indicates the direction that the Coulomb force will point between these two particles. Again, these are oppositely charged particles, so we expect them to attract one another. And in order to attract, the force on the positively charged particle must accelerate it toward the negatively charged particle, and so that force must point toward the negatively charged particle. We can then imagine what happens if we were to consider another moment in time. So if we had labeled the original position of the positively charged particle as time equals zero seconds, and then we consider maybe a millisecond later, so at t equals one times ten to the minus three seconds, what has happened to the positive charge? Well, in the intervening time, it has been acted upon by the Coulomb force from the negative electric charge, and so we would have expected it to accelerate, and therefore it should have moved. It should have changed its position in space. And so it could be, for instance, that in that moment later, where time is now equal to one times ten to the minus three seconds, that the positive electric charge is now over here, continuing its acceleration toward the negative charge. And again, in that moment in time, we can consider what is the force on the positive charge due to the negative charge. The arrow that I originally drew has two pieces of information. One is the direction in which the force points, and the length can be taken as representative of the magnitude, the strength of that Coulomb force. We know from Coulomb's law that as the distance between two particles decreases, the force between them increases, and in fact, if the distance between them goes in half, the force between them increases by a factor of four because of the relationship that the force goes as the one over the distance squared. So we would expect now that, having moved a little bit closer to the negatively charged particle, if we were to now draw the new force arrow, well, it would still point toward the negatively charged particle, but its length, its magnitude, its strength will be much greater now because it is much closer to the negatively charged particle. So we see here that if we were to imagine more times in our picture that at some point, the positively charged particle would reach the negatively charged particle. And what we see here is a line, a line that, for a particle that starts out anywhere along this line, it will be accelerated along that line toward the negatively charged particle if it has positive charge. And so we can imagine that anywhere we dropped a positively charged particle on this line, it would accelerate along the blue vector that I've just drawn. What if instead I had started a particle somewhere out here? What if instead I had put the particle off to the right of the negatively charged particle? And again, this is going to be an elementary charged particle with positive charge. Well, again, it would have felt some acceleration, some force due to the Coulomb force, and it would have moved. And then as it approaches the negatively charged particle, the force will become greater and greater and greater and so forth until finally it reaches the negatively charged particle over here. And we might imagine that any particle that comes along this line here would follow this route. And I can draw this extended all the way out to, let's say, infinity. If we were to put infinity over here, infinity way over here, infinity is anywhere off the page. We begin to see a pattern. The lines of force between a positively charged particle and the negatively charged particle that is acting on it point inward toward the negatively charged particle. And no matter where we drop a positively charged particle here, if we were to start it down on this line, it would come in along this direction. If we were to start it over here, it would come in along this direction. If we were to start it up here, it would come in along this direction. Not my best work, but you get the idea. This leads us naturally into the concept of the force field, which you've already seen in gravitation. Instead of having to draw all these situations where we start with a particle and then we move it and then we see how the force has changed and we move it again and we see how the force has changed again, we can instead represent the force vectors themselves around the particle that is generating the force. And so again, if I were to place my negative electrically charged particle here, then those lines of force would all point inward like this from all directions. I'm only drawing a few of them here. We notice a few things.  If I draw eight total lines of force that are meant to simply be representative of all of the lines of force that this thing can exert in any direction, we notice a few things about the drawing. First of all, the lines increase in density as you get closer to the negatively charged particle. They point inward toward the negatively charged particle and they draw closer together. The spacing between the lines here and here and here and here is a lot smaller than it was out here. In a pictorial representation of a force field, this helps you to understand what the strength of the field is doing. If the lines of force are closer together, the field is stronger at that point in space and if the lines of force are further apart, then the force field, the force that a particle would feel is weaker at that point in space. So in this pictorial representation of a force field, you have a lot of useful information that helps you to remember how the electric force field is going to work. Now if you were to repeat this exercise for a positive elementary charge, again putting in the space around it another positive elementary charge, you could map out what the electric field, the force field is going to look like around a positive elementary charge. When we used a little positive elementary charge to kind of probe the force field around the negative elementary charge, we found this picture that all the lines of force point inward toward the negatively charged particle. Again, using a positively charged particle as our probe, this is what the picture looks like. And in fact, it is standard in all of electricity, all of physics involving the electric field and electric force, to use a very tiny, positive electric charge as your reference point. Thanks to Ben Franklin who assigned the definitions of positive and negative and all of the then conventions that followed from that choice, these days we're stuck with the fact that anytime we talk about electrical phenomena, we're doing it with reference to what a positive electric charge would be doing in the presence of an electric field. It's a convention and it is one to be memorized because it is going to repeat throughout the entire course. Whenever you need to know what an electric phenomenon is doing, you have to think about what a positive electric charge would do in that situation, even if the problem on its face involves the motion of negative electric charge. This will seem a little weird, but it's convention, it's to be memorized, and it's something that's gonna come up a lot and I'll repeat it as we go forward in the course. Now let's go over here to the positive elementary charge that I fixed in place here in this grid and think about what happens to our little positive test charge. I'll go ahead and finally label this. This is our test charge. It lets us test to see what the force field would do to a little charge that's positive in sign at that point. Well, like charges repel and so we expect the line of force that the elementary charge fixed in place exerts on the elementary charge we're using to probe the field. We expect that line of force, not the point toward the positive charge, but away from the positive charge. And in fact, anywhere we put our little test charge around here, we'll find that the lines of force radiate outward, not inward from the positive charge. And so we have here our first pictorial representation of fields of force for the electric force. One can test the pictorial representations using the notions of Coulomb's law and see that it gets all the features right as one goes further away from the charge. The force field weakens significantly. If one increases the magnitude of the charge that would be akin to adding more lines of force. So for instance, if I wanted to look at the force field, not of a plus E charge, but a plus two E charge. So let's say that that's what this thing is here now. So I'll make this dot more significant to indicate that I've increased the charge. Well, all I have to do to represent that is double the lines of force that I've already drawn. That's it. So if you want to pictorially represent relative charges, compared to one another. And they have simple relationships to each other. One of them is plus one E and one of them is plus two E or minus three E. You could do a pictorial sketch of this by just drawing a few representative lines of force for the smallest charge. And then for the bigger charges, you can multiply the number of lines you draw. Obviously this gets unwieldy at some point. This is why we have computers to do this for us. And it would be better to use a computer at some point to do this work. And in fact, we'll walk you through a demonstration of exactly this. So we have here pictorial representations of the fields of force. And now we can explore some basic concepts mathematically with the actual electric field. We've been talking about a visual representation of force fields. At every point in space, if we were to drop a tiny little test charge there with positive electric charge, we could figure out what the force is on that charge due to any other charge in the space around it. And based on that, we could map out what the force field looks like. We just have to draw a little vector representing the force and then accelerate the particle along that line of force for a moment. And then in the next moment, repeat the whole exercise again. And by doing this, we could map out trajectories in electric fields. And in fact, I'll show you how a computer does this in a moment. It does it very fast compared to a human being. But we need to introduce some basic mathematical concepts here. It is obviously inconvenient to have to keep talking about a infinitesimal little charge that we drop around a field and then worry about what the size of that charge is. That's kind of nonsense. And in fact, in physics, we have a simplifying concept that lets us forget about for the moment what that charge is that we've dropped in around the electric field and actually just have a concept independent of the test charge's size that lets us write down a mathematical representation of the electric field. We know from Coulomb's law that for any two point charges, the force between them looks like this. There's a constant k and then we have the two charges multiplied. We have the distance between them squared and the denominator. And we have this vector, which indicates the direction from the source of the force to the recipient of the force in Coulomb's law. And it's merely a direction that has no magnitude. Its length is one. Now we could apply this equation to the picture drawn over here at the left. I've drawn q1 and I've said the q1 is a positive charge and I've drawn q2 and I've said q2 is a test charge and that also makes that one positive. And so we could go ahead and work through Coulomb's law if we knew some of the distances involved. Can't figure out what exactly the force is here over where q2 is located. But we're much more interested in the electric field and its behavior. And the electric field is a concept that should be independent of what charge we are using to probe the force around the central particle. So in this case, let's consider the source of the electric field to be q1. And all we care about is its electric field. All we care about is the direction that its lines of force point and the strength, the length of those lines of force. And we could always multiply by charge later, add charge in somehow to get the exact force out. So we can define a new concept here based on the electric force known as the electric field. And it will be written as a capital E with a vector hat over it. And it will be determined merely by taking the electric force and dividing it by the charge in question. In this case, it's q2. So I have an equation for the force up here. And if I would like to know just what the structure of q1's electric field is without worrying about exactly what q2 is, all I have to do is get rid of q2. And that naturally leads into this new quantity here called electric field. You'll note it is a vector just like force. So that means it has magnitude and it has direction. And quite generically, if you can write down what the electric force equation is for any simple or complex distribution of charges, you can write down the electric field that corresponds anywhere in space to that distribution of charges. Now, we're gonna pick a simple one and we're going to just look at that mathematically, how that looks and we'll exercise in class together, problem solving using this concept. So let's look at the point charge, which I've conveniently already drawn here. So I've drawn a point charge q1 and I've drawn schematically what its electric field ought to look like based on our exercises from a moment ago. And I can now substitute in with Coulomb's law, which is the force between any two point charges. I can substitute in with Coulomb's law to get the exact form of the electric field of a point charge. Okay, so let's go ahead and do that. So I know that in general, the electric field is equal to the electric force divided by the test charge. And in this case, I know exactly what the form of the force is. It is kq1q2 over the distance between them squared. Let me label that R12. And then I have the little unit vector R12 hat. And then of course, I still have to multiply by one over q2, which started out in the denominator over here. This is nice. You see right away, this is a really convenient concept. This serves to simplify Coulomb's law to a slightly simpler equation without a second charge. And that's what's really beautiful about the electric field concept. You have kq1 over R12 squared, R12 hat, and that's it. So this right here, a slightly simpler equation than Coulomb's law, has all the information we need in it to describe mathematically the electric field of a point charge. So let me be very clear about this. This is only for a point charge. So if you are working a problem where you can either directly use a point charge or approximate something as a point charge, then this is a great formula. If you can't approximate something as a point charge, then you have to go back to the original equation and figure out exactly what F is, and then use F to solve for E. So not all problems will necessarily be simple, but there may be some simplifying assumptions that you can make, or you might be handed a really easy problem involving just a couple of point charges, in which case this is very straightforward, and you can apply this directly. So the electric field of a point charge can be written directly as K, Q1 over R12 squared, R12 hat. And you can say here that we are looking at the electric field of the point charge, Q1. So let's see that this has all the right features. So again, let me draw my point charge, Q1. Now, I'm gonna draw another point. I'm gonna call this point P. It's just a point in space. There's no charge there. It's just a point. We're gonna look at what this vector, E vector sub point looks like at that point P. Well, we can use the lessons, Glean from setting up Coulomb's law problems to understand all the pieces here. So K is just a constant. It's positive, so it's just a number. And whatever it does at the end of this, it's just gonna multiply everything else by some positive number. It doesn't change the sign of E, doesn't change the sign of any other numbers in there. So we can ignore it. It's just a number that scales up a vector, up or down. We have Q1. Well, in this case, I said that Q1 was a positive charge. So I said that Q1 is greater than zero. It's a positive number. And let's keep that kind of in our back pocket. That's gonna come in handy later. So Q1 is also a positive number. It's just gonna multiply whatever else is in the equation to scale it up or down. Then we have one over the distance squared. Okay, well, so here's one and here's P, which we can call point two. So the point P is also point two here. And we know that the convention is, is that the vector R12 always points from the source of the force to the place where the force is acting. So let's go ahead and draw that. So here is, by convention, R12 vector. And it points from Q1 to the point P. Well, our hat is just the unit vector that points in that same direction. So there's our hat, one, two, and it has a length of one. And then finally, the magnitude of R12 vector is just the distance between these two points here. Okay, whatever this distance is in meters, centimeters, millimeters, whatever it happens to be, that's what you need to get for the magnitude. Magnitudes are positive. So we know that R12 squared is also positive. And our hat is just a direction. And in this case, it points from Q1 out to two. So this lets us now write down the direction of the electric field due to Q1 at point P. We see that the only thing that carries direction information is R12 hat. And it points from Q1 to the point P. And so we can take that vector and we can use it to represent the direction that the electric field points. So up here at two, we can transport that vector. And we know that that is what E hat is going to look like. That is the direction that E points in is the direction that R12 points in. And then finally, we have to multiply by Q1K and one over R12 squared to get the length of this thing scaled correctly. And so we don't know quite what this is gonna look like. I haven't told you what Q1 is. We know what K is. I haven't told you what R12 is. So I'm just gonna make up an arrow here. I'll just make it longer than E hat for now. And we'll call that E vector. And so what we found is K is a positive number. Q1 is a positive number. R12 is a positive number. R12 hat is a direction that points from Q1 to the point P. And it only carries direction information. So we know already that none of the numbers here change the sign of R12 hat. And so E vector, E point in this case, will in this particular instance point in the same direction as R12 hat. Now let's consider a slight modification to this. Let's consider a negative charge. So let's say we have negative Q1. So Q1 was a positive charge and now I'm gonna flip it sign. And then again, I'm going to have a point P where I'm measuring the electric field. And so I can set all this up again using the formula. K is a positive number. I've now flipped the sign of Q1 and made it negative Q1. So let's keep that in mind. We'll hold that in our back pocket as well. R12 squared is still the distance squared between these points where Q1 is located and where P is located. So that's R12 magnitude. We know that the R12 by convention, R12 vector still points from Q1 negative Q1 to P that hasn't changed. And we know that R hat 12 also points, indicates that direction from negative Q1 to the point P. So the picture hasn't changed. The vector R12 still points in the same direction it did before for the positive charge. But what has changed is the sign of the charge. And so now for a negative charge, if I were to write down E point, what I would find is this is equal to K negative Q1 over R12 squared, R12 hat. And I can, if I'm gonna denote this as the electric field of a negative point charge, I'm gonna put a little minus sign up here in the superscript. And I'm gonna pull this minus sign that's multiplying Q1 out. I can move it anywhere I want. If writing this here is equivalent to writing negative one times Q1. So I can move that negative one anywhere I want. All of these numbers are multiplied together and I can multiply the negative one by anything I like. So I'm going to choose to move it entirely outside of this entire expression and then group all these terms together. And what we see is that whereas the positive electric point charge field pointed outward from the positive charge, the negative electric point charge field has the reverse direction. That minus sign flips the vector of the positive electric point charge field 180 degrees. So over here, we had Q1, which was a positive charge. It's electric field lines point outward like this. Down here, we have negative Q1, a negative point charge. And all the only difference between these two, assuming that the magnitudes of the charges are the same, is that the arrowheads flip. And we see that this beautifully mirrors if you were to rewind the video and look at the sketch we made of the force fields using a positive test charge. This beautifully mirrors what we saw in those pictorial representations of electric fields using positive test charges. That is, this electric field and this electric field point in the directions that would represent the lines of force on a positive test charge dropped somewhere in space around the charge we're probing. But without actually having to have that test charge appear anywhere in the picture, that's the beauty of the electric field concept. And what you see here are in fact the electric fields four point charges, positive point charge and a negative point charge. Having motivated the pictorial representation of the electric field by starting from the force concept and then having defined mathematically what the electric field is in terms of force, that is, it's force per unit charge, force divided by test charge, for instance. We can now identify the units of the electric field. If the units of force are newtons, which you learned in 1307, and the units of charge are coulombs, then if one takes force and divides it by charge, the units of electric field must therefore be newtons per coulomb. And we can see that very clearly in this table, which comes from the textbook. We can then consider what different electric field strengths that may be common to you or perhaps unfamiliar to you would be like and how they compare to one another. So for instance, if you were to sit right at the surface of the nucleus of a uranium atom, remember a nucleus of an atom is a collection of protons bound together with a collection of neutrons. And it's the number of protons that determines the chemical element. If you were sitting right on the surface of uranium's nucleus, you would experience an electric field of strength in newtons per coulomb three times 10 to the 21. And that's because you're essentially sitting right on top of a ball of fundamental particles and you're right next to them. So you're getting almost the full effect of their electric field. And think of the protons as point charges and then think of putting yourself next to a whole clump of point charges. If you remember the field picture that we had a moment ago, you're going to experience the strongest possible electric field that you could get around a bunch of protons by sitting right there. So this is a big field. Three times 10 to the 21, newtons per coulomb is huge. Now, if you were instead to travel out from the nucleus and go, you know, let's say within a hydrogen atom out to a radius that's approximately the typical orbital radius of an electron in a hydrogen atom, something known as the Bohr radius, which is about 5.29 times 10 to the minus 11 meters, if you were to sit at that distance from the single proton at the center of a hydrogen atom, then you would experience an electric field of strength five times 10 to the 11, newtons per coulomb, significantly weaker. You're now further from a single proton because there are fewer protons in hydrogen than there are in uranium, and because you're further away, you would expect a significant fall-off in the strength of the electric field, and that's certainly what we see here. What about something we're more familiar with? What about sparks? Static electric jumps, the charges in the air, lightning strikes, things like that. What happens when that phenomenon occurs? When you see a spark in air, which I demonstrated in class, what you're seeing is the movement of electric charge as the nitrogen molecules in the air are ripped apart and become perfect conductors. So normally air is an insulator. It doesn't really allow electric charge to move very freely, but if you put a strong enough electric field on air, eventually you will tear the electrons, let's say in nitrogen, away from the nuclei in nitrogen, and you will separate those charges, and you'll create what's known as a plasma, and a plasma is merely a gas of electrically charged particles that are weakly or not at all bound to one another. And as a result of that, you'll essentially generate a perfect conductor. This is something known as breakdown. This is when you take a conductor and you turn it, you take a, this is something known as breakdown. This is when you take an insulator and you turn it into a conductor by subjecting it to such a huge electric field that it changes the properties of the material and completely alters the chemistry of what's going on in the physics of what's going on. So what does it take to break down air? Well, it takes an electric field of about three million Newtons per Coulomb, or three times 10 to the six Newtons per Coulomb, to cause air to become a conductor. This is bad. You never want air to become a conductor, especially for instance, if you're in the midst of storm clouds, if you are anywhere near air in the presence of an electric field that strong, you are about to get struck by lightning because the air molecules are about to break down, making a perfect path of conduction from wherever the charge is built up in the clouds to wherever you are, and you will receive some or all of the full brunt of that blast of electrons, as it moves, say, from cloud to ground, or if the electrons are building up in the ground from ground to cloud. It's bad either way. What about near the charged drum of a photocopier? Well, photocopiers make images by using electric fields and electrically charged droplets of toner. So those toner particles that you get in the cartridge and a laser printer or in a photocopier drum, those are designed to be attracted to specific locations by electric fields, and in doing so, make little dots, and building up all those little dots will replicate the original document. The electric fields inside of a photocopier drum are typically something like 10 to the five Newton's per Coulomb. So not air breakdown because that would be bad if the photocopier drum was capable of making electric fields at a million Newton's per Coulomb, three million Newton's per Coulomb, you'd have sparking and arcing all the time inside of a photocopier, and that would be really terrible. It would destroy the photocopier. What about near a charged comb?  Well, try it sometime if you have never done it.  You'll notice your hair stands on end. That's because you've either added electrons from the plastic to your hair or soaked electrons up from your hair and put them on the comb. But this will cause a net charge on your hair that will make it frizz out. And you'll have a corresponding, equal but opposite sign charge built up on the comb. And if you were to move that near a metal sink fixture, you could get a spark that would jump through the air. So the electric fields near a charged comb are typically about 1000 Newton's per Coulomb. In the lower atmosphere where we basically live, typical electric fields are sort of the order of 100 Newton's per Coulomb. That's good because otherwise lightning would be a very common phenomenon. And if you were to go inside of the copper wire of household circuits where electric fields are used to move charges from one place to another. Remember I said earlier that electrons in wires, electrons in conductors are like water in plumbing pipes. You can move them around, you can make them do work for you. Well, copper wire is the plumbing of household circuitry. And the electrons are the water that flows through them. And the way you get those electrons to move is you set up electric fields. And those electric fields don't need to be very strong. They're typically a hundredth of a Newton per Coulomb. Electrons aren't that heavy, they can be easily motivated to move from place to place. And so you don't need a strong electric field to move things around. Nonetheless, the electric fields inside of home wires, copper wiring can be dangerous and you should never touch them because if you touch them and the other half of your body is connected to ground, as we'll learn later, this will cause you to get electrocuted. And it's not a pleasant experience. So having pictorially introduced the electric field concept and then having looked at the electric fields from singular point charges, we can now make a more complicated situation and look at the dynamics of charges in the presence of electric fields, just again, point charges. But we're gonna use a computer program to do this because it's a lot easier to have a computer do repetitious calculations than it is to do all this sketching by hand. And this is the last thing we're gonna look at in this lecture. I've been doing a lot of hand sketching but hand sketching only gets you so far. It's much more interesting to see the dynamics of electric charges and the fields around them, what happens to the fields as electric charges interact by using a computer. The computer is capable of taking the point charge equation, the electric field equation in general and implementing it and doing thousands or millions of calculations a second and updating pictorially and accurately the representations of the electric field. So I have here a grid which represents a space, a two dimensional space into which I can put electric charges. So let me go ahead and do that. And what I'm going to do is I'm going to put a negative electric charge. I can choose its charge, its sign and its mass. I'm just gonna leave these properties alone for now and go ahead and add one of those into the picture. And you see here that this creates a little ball which represents a negative electric charge. And what's kind of cool about this is that I can put it here on one of the grid points in the space. And what you see in the space around it are those little vector field representations of the lines of force. If I were to drop a little positive test charge in here, that would then tell me where the acceleration on that positive charge would point. That is where's the force point on that positive test charge. So you see as in my pictorial representations, the lines of force are longer and denser as you get closer to the charge and they spread out and they get shorter and further apart as you go further from the charge. In addition, what you also notice is that this is a negative charge and indeed the lines of the electric field, the vector arrows of the electric field point inward to the negative charge. So the negative charges are said to be the sinks, the recipients of electric field lines. Electric field lines end on negative electric charges and they begin on positive electric charges which are said to be the source. Now I can go ahead and remove that and instead I can add a positive charge just by changing the sign of the charge. And you'll see that everything flips around. But if I can get this back onto the grid point where it was on a moment ago, good enough. You see here now that the electric field diminishes in the same way as for the negative electric charge but the lines of electric field point outward from the positive charge, not inward. So positive charges are said to be the sources of electric field by convention. Negative electric charges are said to be the recipients or sinks of electric field by convention. And that's all because of this convention of using a positive charge to define everything regarding the electric force and electric fields and so forth. What I'm gonna do now is I'm going to put a negative charge back on the board.  Now there are two ways I can do that. I can have the computer literally fix it in space but unfortunately this simulation doesn't let me do that. Instead I'm going to use a physics alternative for holding something in space. I'm gonna make it super massive and as you know as you increase the mass of something you increase its inertia. Inertia is the tendency to resist changes in motion. So if I have a huge mass, I have a huge capacity for resisting changes in motion. So if I'm at rest, it will be very hard to get me to not be at rest anymore. And so I'm gonna make the mass a thousand for this negative charge and I'm gonna add it into the board. What I'm gonna do is I'm gonna put it down here in the corner of the board. You see the field is still there but it's very weak out here. Now what I'm going to do is I'm gonna add a positive charge with a smaller mass. I'm gonna set that back to one. And I'm going to add that into the board. Now I have paused the simulation so that no time is passing. And this gives me a moment to kind of drop this in. Now what have you noticed? You've noticed that when I added in this positive charge, let me remove it again. Okay, so here's what the field looked like out here and then I added in the positive charge. See the field has changed. It's bigger now than it was. And that's because I've added in a positive charge with the same magnitude charge but different sign. And so the electric field from that should look identical to that of the negative charge except it should point outward from the positive charge and inward to the negative charge. And electric fields are vectors. They add like vectors. So anywhere I put this positive charge, its electric field combines at a point in space. You can see this here, watch. So out here, there's very little of the negative charge's electric field present out here. And there's very little of the positive charge is electric field present here. But as I move the positive charge in closer to this point, watch what happens, it grows in strength. And that's because that point is getting an additional piece added into it, in this case in a positive way that increases the length of the vector. If I now move past this point, what happens is that the electric field of the negative charge, which points down to the left corner, has only a tiny length. But the electric field of the positive charge, which points outward from the charge, and on this side it points back toward this corner, it has a big strength because we're very close to the positive charge. And so the sign of this vector reverses because the positive electric field dominates. And you can see that flip happen again here. Watch, I'll bring this in. Watch this point right here very closely. Remember the electric field lines on this side of the positive charge all point down to this corner. And on the upper right side, they all point up to the upper right corner. And as I move closer to that point I was indicating, you see it grows in length. I'm now adding in the positive charge's electric field. And then as I pass that point, I'm still adding in the positive charge's electric field, but the sign has reversed and it wins. And as I move it closer to the negative charge, we see that that arrow will diminish in strength again, back to roughly what it was before. Now this is all being done statically. I'm moving this charge around by hand. If I was to allow time to pass, we could watch the acceleration between these two charges happen. Remember I've made this one very massive. It has a huge inertia. It will tend not to move very much, even though it is being tugged on by the positive charge. The positive charge has a tiny mass and so it's much less resistant to the force of the negative charge and it will tend to accelerate a lot faster as a result. Watch, I'm going to add time to the simulation. You see a slow acceleration, but as we get closer to the negative charge it picks up and then boom, they collide with one another. So this gives you a sense of how you can use a computer for instance, to represent the mathematics of electric fields and Coulomb's law and get all kinds of interesting dynamics out of it. So normally in class, when we're talking about problems, we're typically dealing with something called statics. That is the charges are fixed in space and we're just trying to figure out at that moment in time what are the forces on each of the particles involved or how do those forces add up and what's the total force. You can do dynamics as well. Dynamics means you let time pass and then you have to calculate the acceleration and how it changes and how the position changes at each step in time. That's very cumbersome. It's better for a computer to do that because computers are very good at repetitious tasks and that's exactly what this simulation program can do with electric fields. So I hope you've enjoyed this little demonstration and what we're going to do now is we're going to use the electric field concept in class and exercise problem solving so that you can see how all these pieces fit together.